Search code examples
csswordpressfunctionstylesheet

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.


Solution

  • 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...