Last active
October 6, 2016 11:15
-
-
Save jackreichert/c8b55b2f357cff8c44ac to your computer and use it in GitHub Desktop.
Enqueuing Fonts in WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.