We don’t want to add direct links to our style.css and other css files in the header.php – let’s keep it clean there!
Instead, add the following to your theme’s functions.php:
/* Enqueue css /* ------------------------------------ */ function alx_styles() { wp_enqueue_style( 'style', get_stylesheet_uri() ); wp_enqueue_style( 'font-awesome', get_template_directory_uri().'/fonts/font-awesome.min.css' ); } add_action( 'wp_enqueue_scripts', 'alx_styles' );
In this example, I am loading style.css and a Font Awesome css file that is in the theme’s subfolder named /fonts/.
Note, in order for this to work, your theme must have this inside the header.php < head >
tag:
<?php wp_head(); ?>
Function reference: wp_enqueue_style