• Resolved Reh Boot

    (@reh-boot)


    Hello,

    hope somebody can explain how to disable google fonts from loading from CDN. I tried what @thingswelike posted before.

    I installed a blank wordpress only with chaplin theme.
    The functions.php in the child theme:

    <?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 );
    ?>

    When a font is selected in the customizer fonts are still loaded from fonts.googleapis.com

    Thank you very much!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Theme Author Anders Norén

    (@anlino)

    Hi @reh-boot,

    You’ll have to modified the enqueues used by Chaplin (the parent theme) to not include the Google Fonts CSS. Try adding this to your child theme:

    function child_remove_google_fonts( $css_dependencies ) {
    	unset( $css_dependencies['chaplin-google-fonts'] );
    	return $css_dependencies;
    }
    add_filter( 'chaplin_css_dependencies', 'child_remove_google_fonts' );

    That should remove the CSS from Google Fonts (which loads the fonts) while still outputting the custom font-family values.

    — Anders

    Thread Starter Reh Boot

    (@reh-boot)

    Great! It works!

    THX

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Unable to disable fonts from loading from CDN server’ is closed to new replies.