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.

Edit header.php

          <?php wp_head(); ?>
     <body <?php body_class(); ?>>
          <?php wp_body_open(); ?>
          <?php wp_footer(); ?>

Edit functions.php

function wpza_after_body_tag_code() {
     echo 123;
add_action( 'wp_body_open', 'wpza_after_body_tag_code' );