DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

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 recipe to do it.

Edit the code below and update the .js file path on line 2. Then, simple paste it on your functions.php file. Save the file, and you’re done!

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' );

Thanks to Devin for this useful tip!

Tags

3 Comments

  1. great tip!
    there is a small error in the code above. the 2nd function name does not match the name called in the action. One is “light_typekit_inline” and the other is “theme_typekit_inline”.

  2. Thanks, it have been corrected 🙂

  3. Great tip! Thanks sharing! 😉

Leave a Comment

Your email address will not be published. Required fields are marked *