Typekit is a useful service which allow you to use countless different fonts on your website or blog. They do provide a WordPress plugin to easily add their fonts to your WordPress site, but there’s no built-in solution for integrating Typekit fonts directly to your theme. Here’s a code to do it. Assuming you don’t want to use the TypeKit plugin, here’s how to enqueue the scripts directly from your theme:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /** * 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 light_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' ); |