(whisper it) it doesn’t work
<whisper>It does if you use it correctly. </whisper> 😉 You should be enqueuing via your theme’s functions.php file – not header.php – using something like:
// Enqueue CSS
if (!function_exists( 'my_theme_style' ) ) :
function my_theme_style() {
wp_register_style('my-style', get_stylesheet_directory_uri() . '/stylefile.css', array(), '', 'all' );
wp_enqueue_style( 'my-style' );
}
endif;
add_action('wp_enqueue_scripts', 'my_theme_style');
<whisper>ok, I was wrong</whisper> 🙂
I’ve seen it widely written about in the way I described and it was also in the responsive theme header so I thought it was something arcane that I didn’t know about.
I REALLY want a stylesheet below the main block of stylesheets output by wp_head, like this:
Block of stylesheets output by wp_head()
Internal stylesheet created by advanced user that selectively over-rides defaults
External stylesheet selected by the novice user that applies a whole load of color changes side-wide
AND
blank custom stylesheet that can be duplicated in a child theme without the need to duplicate header.php
Let me rethink this. The external stylesheet probably won’t over ride the internal stylesheet, even though it’s below it. Rats. But if it does – I’ll have to test this, more rats – is there any way to get an external stylesheet where I want it?
Have you tried using a higher priority on add_action()? In theory, that would cause your wp_enqueue_script() to to be executed later. say something like:
add_action('wp_enqueue_scripts', 'my_theme_style', '20');
http://codex.wordpress.org/Function_Reference/add_action
The external stylesheet probably won’t over ride the internal stylesheet, even though it’s below it
It would if it had higher specificity for it’s ids/classes.
<Have you tried using a higher priority on add_action()? In theory, that would cause your wp_enqueue_script() to to be executed later>
But still within that block of wp_head() outputted stylesheets. Is there no way to output an individual stylesheet ANYWHERE that I want in the head?
<It would if it had higher specificity for it’s ids/classes. >
Good point.
Thanks. 🙂
But still within that block of wp_head() outputted stylesheets.
Yes but wp_head() should be the very last thing before </head>, so altering the priority should work. I don’t think that any other approach is going to be acceptable to the theme review team.