Skip to content
Advertisement

Load customer header.css AFTER theme’s style.css

I’ve got the following PHP code at the bottom of my functions.php:

wp_enqueue_style("header", get_template_directory_uri() . "/css/header.css",  25);

It loads the CSS, but it is at the very top of the chain. I want to override a setting in style.css, which in the wp_head function gets loaded later. I’ve put the priority (as you can see here) to 25, however its not making any difference.

How can I get it load later?

Advertisement

Answer

Find the place in your parent theme that enqueues style.css and get the handle for that stylesheet (most likely “style”) and use that in the dependencies arg.

wp_enqueue_style("header", get_template_directory_uri() . "/css/header.css",  array("style"));

This tells WordPress that your stylesheet is depenent on the “Style” stylesheet and will change the load order accordingly

wp_enqueue_style(“header”, get_template_directory_uri() . “/css/header.css”, 25);

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement