Last active
August 9, 2019 11:20
-
-
Save deeman/86a9e2ca80f1643882a4d1d015f97e7c to your computer and use it in GitHub Desktop.
How to enqueue Font-Awesome in WordPress
This file contains 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 | |
//* 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