Skip to content

Instantly share code, notes, and snippets.

@macbookandrew
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macbookandrew/127a1169f934bfd9e7a9 to your computer and use it in GitHub Desktop.
Save macbookandrew/127a1169f934bfd9e7a9 to your computer and use it in GitHub Desktop.
WordPress—deregister built-in webfonts
// deregister Bitter and Open Sans webfonts only
function deregister_default_fonts() {
wp_deregister_style( 'twentythirteen-fonts' );
}
add_action( 'wp_enqueue_scripts', 'deregister_default_fonts', 100 );
// remove default fonts, add custom fonts, and use a custom minified stylesheet and register but don’t enqueue style.css with all the theme information
function add_custom_css() {
wp_enqueue_style( 'theme-style', get_stylesheet_directory_uri() . '/style.min.css' );
wp_dequeue_style( 'twentythirteen-style' );
// fonts
wp_dequeue_style( 'twentythirteen-fonts' );
wp_deregister_style( 'open-sans' );
wp_register_style( 'open-sans', false ); // dependency workaround from https://gist.github.com/thetrickster/8946567
wp_dequeue_style( 'bitter' );
wp_enqueue_style( 'webfonts', '//fonts.googleapis.com/css?family=Alegreya+Sans:400,700,400italic|Alegreya:400,700' );
}
add_action( 'wp_print_styles', 'add_custom_css' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment