I have written a basic gallery plugin that uses wp_enqueue_style to include a stylesheet on the page. I'd like for the WordPress theme to be able to override the style of the plugin which means I'd like to my plugin to play nice and output the css file before the theme css file.

wp_enqueue_style has a deps parameter for exactly this requirement. My question is what value should I use for the deps parameter if I want to say "I depend on the themes css file"?

The current plugin code is incorrect because it uses false for the deps parameter:

   // Enqueue a CSS style file - see http://codex.wordpress.org/Function_Reference/wp_enqueue_style                                                         
   wp_enqueue_style('bitvol_galleria_css', BITVOL_GALLERIA_URL . '/bitvolution-image-galleria.css', false, $this->bitvol_galleria_version, 'all' );

2 Answers 2


First issue - you have dependency backwards. Depending on something means loading after dependency, while you want earlier.

Second issue - theme's stylesheet doesn't actually use enqueue, it is usually codded directly in header.php file of theme. And since it seems to come before wp_head() call - you have no hook to ensure your stylesheet is above it.

So this is commonly handled like your workaround - queued stylesheet with option to disable it by code or option in admin.


I thought I'd post my workaround which I'm using until I know the answer to the question...

My workaround is:

  1. Cut & Paste the CSS code from the plugin, into the theme (i.e. style.css) and modify it as needed.
  2. Tell the theme to block the plugin from outputing a stylesheet by deregistering it in functions.php:

Code to put in functions.php:

add_action( 'wp_print_styles', 'my_deregister_styles', 100 );

function my_deregister_styles() {
  wp_deregister_style( 'bitvol_galleria_css' );

In some respects, this workaround could be the better solution? (because the website performance will be better by minimising the number of CSS resources included in the HEAD section).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.