Can you not use dependencies, i.e. add your style sheet as a dependency of all the others?
https://developer.wordpress.org/reference/functions/wp_enqueue_style/
@alanfuller , Yes I have used dependencies, for all other css files to be dependent on bootstrap file, so they are coming after bootstrap, but how I can make inline generated css by wordpress to be dependent on bootstrap css file ? If you look at the source view-source:https://uniquesweb.co.in/ntheme/
for example <style id='global-styles-inline-css' type='text/css'>...
or
<style id='wp-block-group-inline-css' type='text/css'>
.wp-block-group{box-sizing:border-box}
.wp-block-group.has-background{padding:1.25em 2.375em}
</style>
etc are coming first and then the bootstrap link file
<link rel='stylesheet' id='unibsstyle-css' href='https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css' type='text/css' media='all' />
, how I can move those inline style tags down the bootstrap link tag ? If its possible through dependencies, how we can give dependencies to those inline style tags ?
I don’t know the answer but there is a filter
print_styles_array
which I think has an array in order of dependency so you may be able to unset your tag and place it at the top.
https://developer.wordpress.org/reference/hooks/print_styles_array/
There may well be a better approach though.
I am not much aware about how to use print_styles_array filter, I want to move my bootstrap css file above the style tags generated by wordpress.
see the link view-source:https://uniquesweb.co.in/demo/practice/test-page/ , I want to move my link handle “unibsstyle” above the style tag with id “global-styles-inline-css” , Can you explain how it could be possible ?
My goal is to override bootstrap css with theme.json file.
I have found a solution to this issue and want to share it with all.
Just changing the priority higher then 9 make any custom css included by us comes first in head. Here is my example code
function unique_styles_topinhead()
{
wp_register_style('unibsstyle', 'https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css', array(), null, 'all');
wp_enqueue_style('unibsstyle'); // Enqueue it!
}
add_action( 'wp_enqueue_scripts', 'unique_styles_topinhead', 8 );
Hope this will help someone 🙂