Adding style.css in wordpress, the correct way

I believe using wp_enqueue_style() is basic and more appropriate.

If you wanted the stylesheet to only be referenced on a particular page template then you do this

if ( is_page_template('template-directory/template-name.php')) {
    wp_enqueue_style( 'theme_css', get_template_directory_uri() . '/directory/filename.css');
}

or you just do this if it is not specific to a page template.

wp_enqueue_style( 'theme_css', get_template_directory_uri() . '/directory/filename.css');

This piece of code will need to go in your functions.php file. Read more about it here -> https://developer.wordpress.org/themes/basics/including-css-javascript/#stylesheets

You also want to be careful about the order in which you have referenced your css files -> In which order do CSS stylesheets override?

Leave a Comment