WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to include a functionality in a theme that will overwrite styles from previously included CSS files. For this purpose, I need to be able to display a <style> in the header after ALL stylesheets have been displayed.

Is there a hook to do this?

share|improve this question
up vote 2 down vote accepted

Hook to wp_enqueue_scripts with a high priority number. For example:

function load_my_style_wpse_90225() {
  wp_register_style( 'mystyle', get_template_directory_uri() .'/path/to/stylesheet.css');
  wp_enqueue_style( 'mystyle' );

That should reasonably load last in line.

Basically the same answer as here: Wooslider custom css



share|improve this answer
This is exactly what I was looking for. Wasn't aware that the priority parameters exists for actions too. – hasMobi - Android Apps Mar 13 '13 at 14:08

Although it is generally not recommended, we can hook to the [wp_print_styles][1] action, which displays after wp_head, wp_enqueue_scripts, and wp_enqueue_styles.

So (in functions.php):

function my_theme_custom_css_handler(){
    echo '<style>custom css here</style>';
add_action('wp_print_styles', 'my_theme_custom_css_handler');

For more information and a full listing of actions, you can check the Action Reference in the WordPress Codex.

share|improve this answer
Creating a new style sheet and calling it last in the queue would be the proper way to do this. Else you could just add the styles to the header directly. I don't see the point of this either way. – Jacob Rambo Mar 10 '13 at 18:23
Linking to styles directly in the header is not recommended by the WordPress Codex and is a common reason for rejecting a theme from approval in the Theme Repository. – hasMobi - Android Apps Mar 10 '13 at 21:42
Yes but you were already going to use a method that was not recommended. What is the difference? Beside when I said directly I meant with style tags <style></style> – Jacob Rambo Mar 10 '13 at 21:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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