• Resolved thingswelike

    (@thingswelike)


    I just realised that the client isn’t see the fonts as intended.
    I didn’t notice because I have the fonts installed locally.

    Have I done something wrong with the enqueue?

    This is the top of my functions.php:

    function my_theme_enqueue_styles() {
     
        $parent_style = 'chaplin-style';
     
        wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
        wp_enqueue_style( 'child-style',
            get_stylesheet_directory_uri() . '/style.css',
            array( $parent_style ),
            wp_get_theme()->get('Version')
        );
    }
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );

    I could add the google font imports to my child stylesheet, but I just wanted to be sure something else wasn’t wrong.

    Thanks

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter thingswelike

    (@thingswelike)

    BTW I used the customizer to select the fonts.

    My child functions (registering 4 sidebars) and child style are all working fine.

    • This reply was modified 5 years, 9 months ago by thingswelike.
    Theme Author Anders Norén

    (@anlino)

    Hi @thingswelike,

    Chaplin adds the Google Fonts as a dependency to the chaplin-style stylesheet handle, so when you enqueue that handle in the child theme without including the dependencies, the Google Fonts are omitted.

    My recommendation would be to skip the parent theme enqueue in your child theme, and only enqueue the child theme styles in your child theme. You can set the priority parameter of the add_action call to higher than 10 to make sure your child theme stylesheet is loaded after the parent theme CSS.

    — Anders

    Thread Starter thingswelike

    (@thingswelike)

    Fantastic – thank you Anders – and thank you for a terrific theme!
    I used it to jump into gutenberg for 3 of my clients and they are all really happy.
    I’d moved away from WP due to the stranglehold of super-themes with page-builder requirements and vulnerable plugins. It’s good to be back!

    My enqueues now look like below and everything seems to be working as it should.

    <?php
    function my_theme_enqueue_styles() {
     
        $parent_style = 'chaplin-style';
     
        wp_enqueue_style( 'child-style',
            get_stylesheet_directory_uri() . '/style.css',
            array( $parent_style ),
            wp_get_theme()->get('Version')
        );
    }
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles',11 );

    Thanks again!

    Theme Author Anders Norén

    (@anlino)

    @thingswelike Thanks, I’m glad you like it!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Google fonts not loading’ is closed to new replies.