How to add code just below opening body tag in Genesis framework

We need to add two snippets of code, one right below the opening body tag, and the other right before the closing body tag. What is the best way to do this? I checked out the wp_enqueue_script, but it appears the content would be in the head section.

5 Answers
5

Did you even open header.php and take a peek? You’ll see genesis_before() called right after the opening <body> tag – follow the white rabbit and you get:

function genesis_before() { do_action('genesis_before'); }

And likewise for the footer. So…

add_action( 'genesis_before', 'im_a_lazy_copy_paster' );
add_action( 'genesis_after',  'im_a_lazy_copy_paster' );

function im_a_lazy_copy_paster() {
    if ( current_filter() == 'genesis_before' )
        echo '<script>party.start();</script>';
    else
        echo '<script>if ( cops.called() ) party.split();</script>';
}

Leave a Comment