Skip to content

Instantly share code, notes, and snippets.

Created February 21, 2018 07:04
What would you like to do?
Enqueue Google fonts in WordPress theme
* Enqueue custom fonts using protocol relative URL.
* Syntax: wp_enqueue_style( $handle, $src, $deps, $ver, $media );
* Ensure $handle is unique to prevent conflicts with plugins
* Note(s): The pipe (|) operator is used to load multiple typefaces in a single call. We also only load the weights we want * by comma seperating them, instead of loading every available weight.
function theme_prefix_fonts()
wp_enqueue_style( 'theme-prefix-fonts', "//,700|Inconsolata:700", '', '1.0.0', 'screen' );
add_action( 'wp_enqueue_scripts', 'theme_prefix_fonts' );
Copy link

Hi Scottparry,

I always follow the WordPress twenty sixteen theme google fonts including system. now I should leave that?

Best Regards
Abdullah AL Imran

Copy link

@wp-expert the TwentySixteen way is fine too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment