4

I'm adding a node to the toolbar and wish to tweak the css a bit. I don't have any external CSS files and I'm echoing the CSS using the wp_head action hook. Is there a similar action hook that I can use to echo the CSS everywhere? Both front-end and admin area?

3 Answers 3

7

The alternative to wp_head action in admin area is admin_head. But, if your CSS depends on another stylesheet, you should use wp_add_inline_style() function hooked to admin_enqueue_scripts action.

2
  • And is there a single hook that will allow me to echo in both front-end and admin area? Commented Oct 12, 2016 at 7:37
  • A hook to echo in <head> in both sides ... I don't think so, but I'm not 100% sure.
    – cybmeta
    Commented Oct 12, 2016 at 8:18
5

In addition to wp_head and admin_head there's a separate hook for the login screen, called login_head if any custom code is needed there.

( This should have been a comment, but my reputation is still to low. )

4

You could always just hook into both of them from the same function:-

function wordpress_stackexchange_242372()
{
    // Your code here
}
add_action( 'wp_head', 'wordpress_stackexchange_242372' );
add_action( 'admin_head', 'wordpress_stackexchange_242372' );

Pretty sure that should work :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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