2

I am adding a WordPress network to an existing website and one of my requirements is to embed the admin utility within our existing sites' layout.

I've written a custom plugin that registers functions to the admin_head and admin_footer actions. admin_head inserts content inside the <head> tag and admin_footer inserts content near the end of the <body> section.

Is there another action that inserts content immediately after the <body> tag or just before any visible HTML is output by WordPress?

Thanks!

2

2 Answers 2

7

Wordpress 5.2.0 introduced the wp_body_open hook (detailed in the WordPress codex)

// Add code after opening body tag.
add_action( 'wp_body_open', 'wpdoc_add_custom_body_open_code' );
 
function wpdoc_add_custom_body_open_code() {
    echo '<!-- custom code -->';
}
1
  • 5
    This doesn't work for WordPress admin. Aug 11, 2022 at 15:25
3

I don't think there is a hook/filter that you can use. The best you can do is to use admin_footer.

Edit: I was going through the admin-header.php and found an action in_admin_header

Try it. I am not sure if this will solve you problem though.

2
  • Thanks, I haven't found anything since I asked the question either. :/ Apr 17, 2012 at 19:31
  • Sadly, in_admin_header is called inside wp-content, meaning that the adminmenu and a few containing classes have already been output. My goal is to wrap the WordPress admin section in a container. Any other ideas? Apr 18, 2012 at 18:07

Your Answer

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

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