Using wp_body_open()

The useful function introduced in WordPress version 5.2, wp_body_open() gives you the capability of running custom code directly after the opening <body> tag of your WordPress Theme.

Use wp_body_open() the right way

In order to use the wp_body_open() function in WordPress, you need to edit two of your files accordingly, both header.php and functions.php.

<html>
     <head>
          …
          <?php wp_head(); ?>
     </head>
     <body <?php body_class(); ?>>
          <?php wp_body_open(); ?>
          …
          <?php wp_footer(); ?>
     </body>
</html>
function wpza_after_body_tag_code() {
     echo 123;
}
add_action( 'wp_body_open', 'wpza_after_body_tag_code' );