I'm using a third-party theme with a custom child theme on a website and want to remove the Google Fonts from the parent theme within the child theme's functions.php. This is not working - nothing happens.
/**
* Remove parent theme Google fonts
*/
function remove_parent_theme_google_fonts() {
wp_dequeue_style( 'themename_googlefonts-css' );
wp_deregister_style( 'themename_googlefonts-css' );
}
add_action( 'after_setup_theme', 'remove_parent_theme_google_fonts', 1);
where themename_googlefonts-css
is the parent theme's id from the stylesheet link.
Thanks for your help.
EDIT: Removed direct references to specific third-party theme to make this more relevant for other users.
-css
suffix is being added automatically by WordPress so try omitting it. alsoafter_setup_theme
doesn't seem like the current event to hook into, trywp_enqueue_scripts
. You can also play with the priority argument, you have1
at the moment (default is 10), so try a higher/lower priority. You can also use a plugin calledquery monitor
to check the actual CSS handle name-css
suffix. Thanks for the hint! It works withwp_enqueue_scripts
. And I will check the helpful plugin you mentioned.