Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ordering Wordpress Stylesheets?

I have a wordpress theme with a stylesheet that needs to be loaded last, since plugin css are interfering with my theme. I was wondering if there was some type of function I could use to make the main stylesheet load last in my theme.

like image 845
Jamie Avatar asked Oct 25 '11 22:10

Jamie


People also ask

How do I add a stylesheet in WordPress?

Navigate to Appearance -> Customize section of your dashboard, scroll down to the bottom of the page and click Additional CSS. This will open an in-built tool that will allow you to add any CSS code.

Where is the stylesheet in WordPress?

Every WordPress theme contains its style. css file. You can find one in the /wp-content/themes/themename/ folder.

What is WordPress stylesheet?

The style. css is a stylesheet (CSS) file required for every WordPress theme. It controls the presentation (visual design and layout) of the website pages.


2 Answers

when you enqueue your stylesheets, use a higher priority, e.g.:

add_action( 'wp_enqueue_scripts', array(&$this, 'theme_styles'), 99 );

If some plugins have hooks on 'wp_print_styles', then you have to use it instead, as 'wp_print_styles' will be written after 'wp_enqueue_scripts', iirc.

And as you have complete control over your theme, you also could include your styles directly into header.php, if the hassle with the actions isn't worth time...

like image 76
kulpae Avatar answered Sep 19 '22 06:09

kulpae


wp_print_styles works better. just add a priority to the call, for example 99.

function load_css() {
        wp_enqueue_style( 'homepage-css', get_stylesheet_directory_uri() . '/css/homepage-css.css', array(), 0.256, 'all');
}
add_action( 'wp_print_styles', 'load_css', 99 );
like image 42
Mau Avatar answered Sep 22 '22 06:09

Mau