I want to know using wp_register_style function.

wp_register_style('bmg-comp-listing-jquery-timepicker-css-public', plugins_url('css/public/jquery.timepicker.min.css', __FILE__),array('plsh-style-css'));

I tried to pass it like that but its not working. What should the array contain?

1 Answer 1


You have three options to enqueue a CSS after one another. You can either:

Increase the priority of the hook

You can set the hook's priority as follows:

add_action('wp_enqueue_scripts', 'some_function', 999);
function some_function() {
    wp_register_style('bmg- ... -public', plugins_url('...', __FILE__),array('plsh-style'));
    wp_enqueue_style('bmg- ... -public');

This comes in handy when you are using a plugin to enqueue a CSS and do not want to modify the templates, or vice versa.

Enqueue them in order

If you have multiple CSS files you want to enqueue, simply use them in order:

add_action('wp_enqueue_scripts', 'some_function', 999);
function some_function() {
    // First register them
    wp_register_style( 'bmg- ... -public', plugins_url('...', __FILE__) );
    wp_register_style( 'plsh-style', plugins_url('...', __FILE__) );
    // Then enqueue them in order
    wp_enqueue_style( 'plsh-style' );
    wp_enqueue_style( 'bmg- ... -public' );

This will cause my-style to be enqueued after my-style.

Set the depandancies

The third argument of wp_register_style() is an array that indicates the dependencies for this stylesheet. Dependent stylesheets will be loaded before this stylesheet. You might as well want to first register the dependency handler. Take a look at the relevant codex page about this function.

Note: The real handler name does not usually contain -css. This is added automatically by WordPress while enqueuing style. You might want to use plsh-style instead of plsh-style-css. So, This:

wp_register_style('bmg- ... -public', plugins_url('...', __FILE__),array('plsh-style-css'));

Should be turned to this:

wp_register_style('bmg- ... -public', plugins_url('...', __FILE__),array('plsh-style'));

I've removed the links and names to make the code fit in a single line.

  • I saw in the codex but not getting idea of how to? I am looking out for using depandancies. Can you give an example as to what I should pass to the array. Is it file name or id. I am not getting, please help Jul 28, 2017 at 11:53
  • Please try the note I just added. This might solve your problem.
    – Johansson
    Jul 28, 2017 at 11:54
  • I tried it but whats happening is my css is coming after the other css but the other css file is also going on top which should not happen. I mean the other css has changed its order. :( Jul 28, 2017 at 12:03
  • Ok so it's half done. How is the other CSS registered? And which one of the methods of these 3 did you use?
    – Johansson
    Jul 28, 2017 at 12:05
  • I am developing plugin where I need the css of this plugin to include after the theme css or the bootstrap css of that theme. I have used all 3 methods now but I dont see the result as needed. Actually I am using jquery timepicker so i need this timepicker css to appear after bootstrap css of the theme. Jul 28, 2017 at 12:12

Your Answer

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

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