Viewing 13 replies - 1 through 13 (of 13 total)
  • the same for me, WP 5.2.3

    same, it’s a shame ??

    Hi all!

    If in your site don’t work insetr body code, you need insert in theme next code:

    
    <body>
    	<?php wp_body_open(); ?>
    
    ...

    wp_body_open() — launch the wp_body_open hook. Should be used in a theme immediately after the opening <body> tag.

    Thread Starter lcf

    (@lcf)

    not sure why we need to edit the theme code. other similar plugin works just fine.

    I just gave you one of the solutions to the problem. Other plugins also require this hook.

    Same here. At first, I thought it was somehow conflicting with Woodmart, but now that I installed it on a different project & theme, the body injection doesn’t work there either.

    And if I have to edit the (child-) theme files to make it work, then what’s the point in using this plugin? I can always inject the code directly into the theme files.

    Thanks this snippet helped me. In my scenario the point of being able to add it in is to be able to react quickly to requests from the marketing team, so doing a small bit of one-time setup is worth it.

    Following. Same problem, working in header and footer, but not in <body>

    @thomasjons didn’t my solution help you?

    @xenot

    Hi I tried something alike. I did put the below vode in top of my functions.php which didn’t work.

    I can try your exact code, in which file do you prefer me to put it?

    Code I tried with:

    <?php
    if ( ! function_exists( ‘wp_body_open’ ) ) {
    /**
    * Fire the wp_body_open action.
    *
    * Added for backwards compatibility to support WordPress versions prior to 5.2.0.
    */
    function wp_body_open() {
    /**
    * Triggered after the opening <body> tag.
    */
    do_action( ‘wp_body_open’ );
    }
    }

    @thomasjons

    Basic template structur, sample index.php

    
    <html>
    
    <head>
    	... content head ...
    </head>
    
    <body>
    
    	<?php wp_body_open(); ?>
    
    	…rest of site layout…
    
    </body>
    
    </html>
    
    

    Thank, in header.php I added it as below and now it works.

    </head>

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

    @xenot where exactly will I put the code ?

    I am using Astra theme .

    Can’t find <body> tag .

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘fail to insert code to body’ is closed to new replies.