Tuesday, April 2, 2013

How to directly include Typekit fonts on your WordPress theme

How to directly include Typekit fonts on your WordPress theme

How to directly include Typekit fonts on your WordPress theme

Typekit is a very useful service which allow us to use countless different fonts on our website or blog. Typekit provide a WordPress plugin by using this we can easily add their fonts to our WordPress site, but there are no built-in solution by which we can integrating Typekit fonts directly to your theme. Please following tricks can do so.

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


No comments:

Post a Comment

I just got my #domain @BigRock. Get upto 25% off with my personalized coupon link Get upto 25% off