0

I'm using the theme Pixgraphy and created a child theme. Because of recent changes concerning data protection in the EU, I now want to load Google Fonts locally.

The parent theme includes the Google Fonts like this:

wp-content/themes/pixgraphy/inc/settings/pixgraphy-functions.php

/********* Adding Multiple Fonts ********************/
    $pixgraphy_googlefont = array();
    array_push( $pixgraphy_googlefont, 'Open+Sans:400,400italic,600');
    array_push( $pixgraphy_googlefont, 'Merriweather:400');
    $pixgraphy_googlefonts = implode("|", $pixgraphy_googlefont);
    wp_register_style( 'pixgraphy_google_fonts', '//fonts.googleapis.com/css?family='.$pixgraphy_googlefonts);
    wp_enqueue_style( 'pixgraphy_google_fonts' );
    if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
        wp_enqueue_script( 'comment-reply' );
    }

Now in the functions.php of the child theme, I did this:

function remove_google_fonts_stylesheet() {
    wp_dequeue_style( 'pixgraphy_google_fonts' );
}
add_action( 'wp_enqueue_scripts', 'remove_google_fonts_stylesheet', 100 );

From what I read everywhere, this should work. But it doesn't, the Google Fonts are still loaded. This is the website: http://werner-mueller-fotografie.de/

1 Answer 1

0

You may also want to try to deregister the style within your function since it has been register in the parent theme function.

Try:

function remove_google_fonts_stylesheet() {
     wp_dequeue_style( 'pixgraphy_google_fonts' );
     wp_deregister_style('pixgraphy_google_fonts');
}
add_action( 'wp_enqueue_scripts', 'remove_google_fonts_stylesheet', 100 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.