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.