For adding font awesome in wordpress, we need to download and extract font awesome from github and then copy the ‘css’ and ‘fonts’ folder inside our theme directory.
Then we enqueue the css in our functions.php file.
function fontAwesomeEnque(){
wp_register_style('fontAwesome', get_template_directory_uri().'/css/font-awesome.min.css');
wp_enqueue_style('fontAwesome');
}
add_action('wp_enqueue_scripts','fontAwesomeEnque');
add_action('admin_enqueue_scripts','fontAwesomeEnque');
Note: if we use only ‘wp_enqueue_scripts’ hook then the font will be only added to front end. UsingĀ ‘admin_enqueue_scripts’ will enable it to load in dashboard also. So, we use both….