1

I know about wp_head() and admin_head() for hooking into their respective <head>s, but what is the hook for both of these combined, if any?

The purpose is to:

add_action('wp_head', 'custom_css');
add_action('admin_head', 'custom_css');

Just one add_action() instead of two would be cleaner.

Edit

Another question would be, where can I find this information on my own? I see an alphabetical list here, but I can't find any kind of firing order reference.

Edit 2

I don't think there is a hook for both. Correct me if I'm wrong. I'll delete this question if that's the case and the mods think it's a good idea.

3
  • I think this is a fair question, even if the answer is there isn't one. If I was looking myself I'd look for the code that triggers or handles wp_head and admin_head to see what else it calls nearby.
    – Rup
    Apr 8, 2023 at 11:54
  • 1
    There isn’t one because there’s very very few circumstances where you would even want to do this. If you’re adding styles for editor content and front end content then enqueue_block_assets should be used to enqueue a stylesheet which will be used for the editor and the front end. Apr 8, 2023 at 12:40
  • Someone post an answer or I can delete this question. I'd like to keep it up for my reference. e.g. There is no global header hook
    – Jeff
    Apr 8, 2023 at 13:23

1 Answer 1

1

There is no global head hook to target the front-end and back-end in WordPress.

My CSS needs to target the Admin Bar. Previewing a post/page while logged requires both wp_head() and admin_head().

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.