Assuming you don’t want to use the TypeKit plugin, here’s how to enqueue the scripts directly from your theme:
/** | |
* TypeKit Fonts | |
* | |
* @since Theme 1.0 | |
*/ | |
function theme_typekit() { | |
wp_enqueue_script( 'theme_typekit', '//use.typekit.net/xxxxxxx.js'); | |
} | |
add_action( 'wp_enqueue_scripts', 'theme_typekit' ); | |
function theme_typekit_inline() { | |
if ( wp_script_is( 'theme_typekit', 'done' ) ) { ?> | |
<script type="text/javascript">try{Typekit.load();}catch(e){}</script> | |
<?php } | |
} | |
add_action( 'wp_head', 'theme_typekit_inline' ); |
One line 11 I changed
light_typekit_inline()
totheme_typekit_inline()
to get it to workAh, thanks. Copypasta. Fixed it up.
Worked like a charm. Very nifty function wp_script_is … didn’t know about that one!
Many thanks
I’m for code snippet against plugin overkill.
I needed exactly this! Thanks for the snippet. :-)
To add a second or third font, would I repeat the whole snippet in functions or is it easier than I’m guessing?
That should load all the fonts you have set for the site.