

In other words, if you only use two icons, all the other ones will be removed when you run yarn build:production.)

Enqueue font awesome code#
(Tree shaking is a code optimization process that trims unused pieces from bundled assets. Remember: Don’t forget to change the name & path of the font-awesome css file.Use Font Awesome 5 in a Sage 9 theme, loading SVGs via the advanced JavaScript API to take advantage of tree shaking.

Add the complete path to the font-awesome CSS by following your current theme directory.
Enqueue font awesome download#
First download the font awesome icons and keep them within your WordPress theme.To enqueue font-awesome icons in WordPress theme, Wp_enqueue_style( 'responsive-style', get_template_directory_uri().'/css/responsive.css') Īdd_action( ' wp_enqueue_scripts ', ' diwp_include_multiple_styles ' ) Įnqueue Font Awesome Icons in WordPress Theme Enqueuing Multiple Stylesheets or CSS files in WordPress Remember: Don’t forget to change the name & path of the css files. To enqueue multiple CSS files, you can keep them within a function and enqueue them by WordPress hook. Wp_enqueue_style( 'main-style', get_template_directory_uri().'/style.css') Īdd_action( 'wp_enqueue_scripts', diwp_include_scripts_styles) Įnqueue multiple CSS files or Style file in WordPress Theme Enqueuing Stylesheet or CSS in WordPress Remember: Don’t forget to change the name & path of the css file. To enqueue CSS or style file in WordPress theme, add the below code in your theme’s functions.php file. Enqueue CSS or Style file in WordPress Theme Now let’s move on to the enqueuing CSS files and fonts. Remember, this hook will be used for both whether you are enqueuing CSS files for Javascript and jQuery files. It’s always good practice to keep all your styles and scripts within a function and use the wp_enqueue_scripts hook to enqueue them. WordPress also provides a hook to enqueue scripts and styles. So as of now, you have got the idea how this actually works. The default value for this parameter is set for all. The accepted values for this parameter are ‘all’, ‘screen’, ‘print’ and media queries like ‘(orientation: portrait)’ and ‘(max-width: 640px)’. $media – This refers to the media in which this stylesheet should load.By default, It assigns the currently installed WordPress version number with a stylesheet if nothing has passed. $ver – This set the version number for your stylesheet.If you want to load your stylesheet after one or more CSS files then you can pass these stylesheet’s names within an array to set dependency for these files. So this parameter holds the dependency for the current stylesheet.

