Skip to content

Instantly share code, notes, and snippets.

@deeman
Last active August 9, 2019 11:20
Show Gist options
  • Save deeman/86a9e2ca80f1643882a4d1d015f97e7c to your computer and use it in GitHub Desktop.
Save deeman/86a9e2ca80f1643882a4d1d015f97e7c to your computer and use it in GitHub Desktop.
How to enqueue Font-Awesome in WordPress
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
// Load Font Awesome//
// Register Style, Codex version
function custom_styles() {
wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css', false, '4.1.0' );
}
add_action( 'wp_enqueue_scripts', 'custom_styles' );
//LOAD VIA CLOUDFLARE
add_action( 'wp_enqueue_scripts', 'add_font_awesome_cloudfare' );
function add_font_awesome_cloudfare() {
wp_enqueue_style( 'font-awesome', '//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css' );
}
//HOST IT YOUR SELF
/*You can also download the font icons and upload the folder to your
child themes root directory, them load them using PHP code in your functions file.*/
add_action( 'wp_enqueue_scripts', 'add_font_awesome_child_theme' );
function add_font_awesome_child_theme() {
wp_enqueue_style( 'font-awesome', get_bloginfo( 'stylesheet_directory' ) . '/font-awesome/css/font-awesome.min.css' );
}
//Make sure the path to the font-awesome.min.css file is correct. Then use them in your theme like this
// https://fontawesome.com/how-to-use/on-the-web/setup/getting-started?using=web-fonts-with-css
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment