• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Google Fonts not loading in Genesis Sample 3.1.0

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Google Fonts not loading in Genesis Sample 3.1.0

This topic is: not resolved

Tagged: google fonts

  • This topic has 3 replies, 4 voices, and was last updated 2 years, 6 months ago by stafmans.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • October 16, 2019 at 2:06 am #494042
    Mark-C
    Member

    Sample Theme: https://github.com/studiopress/genesis-sample/releases/tag/3.1.0
    Google Font Script: https://gist.github.com/bgardner/4ac2618c7fc0f1650df6

    New WordPress Build: 5.2.4
    Genesis Framework: 3.1.2

    I'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://localhost
    October 16, 2019 at 2:44 pm #494070
    andytc
    Participant

    Are any of these links of any use ?

    https://www.studiopress.com/google-web-fonts/

    Or load them locally -

    https://sridharkatakam.com/video-how-to-load-and-use-google-fonts-from-your-websites-server-in-wordpress/

    October 17, 2019 at 11:28 am #494089
    Victor Font
    Moderator

    Genesis 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 #494289
    stafmans
    Participant

    Victor, 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.

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2022 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble