From the source, reformatted for better readability:
function wp_enqueue_style(
$handle, // unique name
$src = false, // URL
$deps = array(), // array of dependencies, other styleheets unique names.
$ver = false, // version
$media = 'all' // media
)
So, $deps
is an array of unique stylesheet handles. If you list the stylesheets here you want to wait for, WordPress will create the proper order automatically for you.
Example:
$template_dir_uri = get_template_directory_uri();
wp_register_style( 'style_1', "$template_dir_uri/style1.css" );
wp_register_style( 'style_2', "$template_dir_uri/style2.css" );
wp_register_style( 'style_3', "$template_dir_uri/style3.css", array ( 'style_1', 'style_2' ) );
wp_register_style( 'style_4', "$template_dir_uri/style4.css", array ( 'style_3', 'default_theme_css_handle' ) );
wp_enqueue_style( 'style_4' );
Now the <link>
elements for the stylesheets will be printed in the correct order 1, 2, 3, 4.
wp_enqueue_style()
. As @toscho mentions in his answer below, you can tell WordPress that your stylesheet depends on others, and have it after them.