Community Forums › Forums › Archived Forums › General Discussion › Google Fonts not loading in Genesis Sample 3.1.0
Tagged: google fonts
- This topic has 3 replies, 4 voices, and was last updated 5 years, 1 month ago by stafmans.
-
AuthorPosts
-
October 16, 2019 at 2:06 am #494042Mark-CMember
Sample Theme: https://github.com/studiopress/genesis-sample/releases/tag/3.1.0
Google Font Script: https://gist.github.com/bgardner/4ac2618c7fc0f1650df6New WordPress Build: 5.2.4
Genesis Framework: 3.1.2I'm unable to load Google fonts on my new clean WordPress build.
I have tested on both localhost and live environments.
I have amended both functions.php & style.css on the Genesis Sample 3.1.0 child theme.functions.php
add_action( 'wp_enqueue_scripts', 'genesis_sample_enqueue_scripts_styles' ); /** * Enqueues scripts and styles. * * @since 1.0.0 */ function genesis_sample_enqueue_scripts_styles() { $appearance = genesis_get_config( 'appearance' ); wp_enqueue_style( genesis_get_theme_handle() . '-fonts', $appearance['fonts-url'], [], genesis_get_theme_version() ); wp_enqueue_style( 'dashicons' ); wp_enqueue_style( 'google-fonts', '//fonts.googleapis.com/css?family=Open+Sans|Roboto+Slab:700', array(), CHILD_THEME_VERSION ); if ( genesis_is_amp() ) { wp_enqueue_style( genesis_get_theme_handle() . '-amp', get_stylesheet_directory_uri() . '/lib/amp/amp.css', [ genesis_get_theme_handle() ], genesis_get_theme_version() ); } }
style.css
body { color: #444444; font-family: 'Open Sans', sans-serif; font-weight: 400; } h1, h2, h3 { font-family: 'Roboto Slab', serif; font-weight: 700; color: #444444; }
When I launch the site in live, I still see the default font "Source Sans Pro", sans-serif; site wide. No error messages are shown.
When i view source code I see:<link rel='stylesheet' id='google-fonts-css' href='//fonts.googleapis.com/css?family=Open+Sans%7CRoboto+Slab%3A700&ver=CHILD_THEME_VERSION' type='text/css' media='all' />
However when clicking and inspecting:
<link rel='stylesheet' id='genesis-sample-css' href='https://demosite.com/wp-content/themes/genesis-sample/style.css?ver=3.1.0' type='text/css' media='all' />
I do not see the latest CSS changes, yet when i inspect style.css with a code editor or via theme editor the changes are present.
When I launch the site in localhost (Desktop Server 3.9.6), fonts change but I get the following error message:
Warning: Use of undefined constant CHILD_THEME_VERSION - assumed 'CHILD_THEME_VERSION' (this will throw an Error in a future version of PHP) in E:\DesktopServer Projects\DWV\newsampletheme.test\wp-content\themes\genesis-sample\functions.php on line 82
I have tested the same scripts (functions.php and style.css) in localhost and live using Genesis Sample 3.0.1 all appears to work well.
Is there are bug in the latest Genesis Sample 3.1.0 or should I be using a different method to enqueue Google Fonts?
https://localhostOctober 16, 2019 at 2:44 pm #494070andytcParticipantAre any of these links of any use ?
https://www.studiopress.com/google-web-fonts/
Or load them locally -
October 17, 2019 at 11:28 am #494089Victor FontModeratorGenesis 3.x and the 3.1.0 now use configuration files for loading Google fonts. Edit the Genesis Sample config/appearance.php file around line 30 and change the fonts-url attribute to reflect the value of your new fonts.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?October 28, 2019 at 3:53 pm #494289stafmansParticipantVictor, thanks for your very welcome answer. This is quite a different approach. Is it documented somewhere? The tutorials on Studiopress do not explain it like this.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.