Corresponding body-ending hook to wp_body_open?
-
I’m writing a plugin with the goal of it outputting HTML before the theme’s header template part and after the theme’s footer template part – essentially a branding header and footer on the page that appears regardless of what the theme supplies. We have an existing plugin that is not working well, and instead of trying to diagnose it (the original developer is not available for helping), I’m hoping to scrap it and write a new one.
The original plugin uses the ‘shutdown’ hook to hijack the page output and inject HTML after the ‘<body>’ for the header and before the ‘</body>’ for the footer. That didn’t seem all that elegant so I went looking for more appropriate hooks to use.
After a lot of rooting around in the WordPress docs, I stumbled upon the ‘wp_body_open’ hook, and it seems to fit the bill for outputting some heading HTML before the theme outputs its header template part, but I can’t seem to find an appropriate one for the footer. I found ‘wp_footer’, but the docs indicate that the theme has to support it. I’m using a modified version of Twenty Twenty-Four, and it does work with the ‘wp_footer’ hook, but I was hoping to make the plugin more universal.
If anyone has some suggestions for a good hook that fires near the end of the page output, that would be great. Thanks!
- You must be logged in to reply to this topic.