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.
Leave a Reply
You must be logged in to post a comment.
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-upinclude
. 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 thewp_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.