How to link Font Awesome to WordPress sites using wp_enqueue_style function?



Hello Everyone We are back with another WordPress Tutorial after a request from one of our viewer. He asked us How to link Font Awesome to WordPress sites using wp_enqueue_style function? so in this tutorial we will explain you how to link Font Awesome to WordPress sites using wp_enqueue_style function easily. We can easily link to CSS Stylesheets directly by using link tag in the Header Section. But to make it more WordPress Compatible we will add by this method.

What is wp_enqueue_style() ?

wp_enqueue_style is a WordPress built in function for linking or adding external stylesheets this is very secure and Wordpress Recommended way of adding or linking external Stylesheets.

This function contains two mandatory or important parameters. 
  • The First parameter should be a unique name or handle that we want to identify that particular stylesheet we're linking to.
  • The Second parameter should be a link to the stylesheet.

Steps To How to link Font Awesome to WordPress sites using wp_enqueue_style function:

STEP 1: Go To Appearance » Editor » functions.php as shown in the image below:


STEP 2: When You Click on Editor Find functions.php template file.



STEP 3: Copy This Below Code in the functions.php file

function tw_theme_styles() {

    wp_enqueue_style("tw_fontawesome", "https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css");}

add_action("wp_enqueue_scripts", "tw_theme_styles");

That's it Thanks For Following The Tutorial Now Its time For Customization to make it as it made for your site.


Customization:

  • The Yellow Highlighted Text is Responsible for Name of the style you can name whatever you want but make sure it is unique and does not conflict with other stylesheet's name.
  • The Green Highlighted Text is Responsible For Link to the style sheet if you want to add the most recent version of the stylesheet then replace it with the url highlighted in green color.
STEP 6:  All Done Click On Update functions.php To Save the File & Check it in your site.


That's It Thanks For Following our Tutorial '' How to link Font Awesome to WordPress sites using wp_enqueue_style function? '' Along With us If you found any difficulty Please Comment and Share Your Valuable Opinion. And Stay tuned for More Tutorials Like This and Share this with your friends.

No comments:

Post a Comment