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.
Leave a Reply
You must be logged in to post a comment.
Did you even open
header.php
and take a peek? You’ll seegenesis_before()
called right after the opening<body>
tag – follow the white rabbit and you get:And likewise for the footer. So…
You can use a plugin such as this to show all of the Genesis hooks: http://wordpress.org/plugins/genesis-visual-hook-guide/. This will allow you to quickly find the right hook to modify to do this.
Then modify the hook in the functions file.
You can also use a plugin which allows you to easily modify hooks through the wp-admin: http://www.studiopress.com/plugins/simple-hooks
You were on the right track.
wp_enqueue_script
takes a parameter called in_footer which defines whether your script should be loaded before page content or at the end of the page body.Here is the reference on codex: http://codex.wordpress.org/Function_Reference/wp_enqueue_script
After the opening body tag.
Structural Action Hooks
genesis_before: This hook executes immediately after the opening tag in the document source.
You can add the script to the Genesis > Theme Settings > Header and Footer scripts and enter your script you would like output to wp_footer().
The wp_footer() hook executes immediately before the closing tag in the document source.
An update for GenesisWP 3.3.1
Go to header.php