Does anyone know a good way to hook just after get_header() without hacking the theme? I know you can hook before the function loads header.php but I am trying to insert some HTML just after get_header() is finished.

1 Answer 1


I hate answering questions in the negative because it is easy to go wrong, but there is no core hook that does that-- at least no hook that I have ever seen. I admit it could be handy for a couple of things though.

wp_header() loads the theme's header file. That is about it. It is really just an amped-up include. If you look at the source, there is a hook that runs before the header file is loaded, but not one after.

It is possible that your theme has provided a hook though. I am thinking that that is the only chance you have of this working.

You could do this with Javascript, if that is an option, then you could hook the script to wp_head and wouldn't need to hack the theme. That is, you could load Javascript into the page <head> using the wp_head hook, and that Javascript could insert your HTML into the page body. It is not a great solution but given your condition about not editing the theme and given that there are no hooks you can rely on across multiple themes, that is the best I can think of.

  • +1. wp_head is the correct template action to use to add HTML to the document head. If the intent is to add content to the document body, then you'll have to wait for Twenty Thirteen, which will include standard template hooks. Commented Feb 20, 2013 at 16:08
  • Standard template hooks? I am intrigued. Commented Feb 20, 2013 at 17:05

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.