I´m creating a child theme for Twenty Twelve v1.0 and I want to remove the Open Sans font.
Open Sans is added in Twenty Twelve´s functions.php:
wp_enqueue_style( 'twentytwelve-fonts', add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" ), array(), null );
I´ve tried to deregister/dequeue the stylesheet in my childtheme´s functions.php (see examples below) but to no effect:
function example_scripts_styles() {
wp_deregister_style( 'twentytwelve-fonts' );
wp_dequeue_style( 'twentytwelve-fonts' );
}
add_action( 'wp_enqueue_scripts', 'example_scripts_styles' );
Any ideas how I can remove this file?
Thanks!
Found the answer here:
Following the same logic we can use
wp_print_styles
to remove the Open Sans font:This did the trick.
On WP 3.8+, I sucessfully removed ‘Open Sans’ from my frontend styles using thetrickster’s gist:
‘Open Sans’ can be a plugin dependancy.
In the functions.php of Twenty Twelve v1.1, a comment explains how to remove the stylesheet from the
wp_enqueue_scripts
hook:Your attempt that didn’t work was missing the priority parameter in the
add_action()
. The parent theme enqueues the style with the default priority of 10, so the child theme has to dequeue it with priority 11.You’ll find that WordPress itself also loads Open Sans (at least version 3.8). In fact, it was loading Open Sans three times for me: one for the WP admin, one for the TinyMCE editor, and another for the page.
If your goal is removing Open Sans altogether, you’ll have to hack WordPress itself (or stay with an older version).
My own code to remove the Open Sans (at least when a user isn’t logged in, which is most of the time) is my theme’s
functions.php
:twentytwelve_scripts_styles
has everything intwentytwelve_scripts_styles
except the bit that loads Open Sans.