Skip to content

Instantly share code, notes, and snippets.

@jackreichert
Last active October 6, 2016 11:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackreichert/c8b55b2f357cff8c44ac to your computer and use it in GitHub Desktop.
Save jackreichert/c8b55b2f357cff8c44ac to your computer and use it in GitHub Desktop.
Enqueuing Fonts in WordPress
<?php // add the following into your theme's functions.php
function theme_fonts() {
// typekit
wp_enqueue_script( 'theme_typekit', '//use.typekit.net/xxxxxxx.js');
// fonts.com
wp_enqueue_script( 'theme_fontsdotcom', '//fast.fonts.net/jsapi/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js');
// google fonts - Josefin (a favorite)
wp_enqueue_style( 'theme_googlefonts', '//fonts.googleapis.com/css?family=Josefin+Sans');
}
add_action( 'wp_enqueue_scripts', 'theme_fonts' );
// 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' );
@jackreichert
Copy link
Author

Each of the above tools have their own way to create a collection of fonts, and all have great walk-throughs. Once you generate one replace the above code / paths with your custom generated one. Don't forget to comment out, or remove what you're not using.

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