Community Forums › Forums › Archived Forums › General Discussion › Move genesis_inpost_scripts_box to Footer
Tagged: genesis_inpost_scripts_box
- This topic has 3 replies, 2 voices, and was last updated 10 years, 7 months ago by Gary Jones.
-
AuthorPosts
-
August 28, 2013 at 4:57 pm #59341jkirkerMember
What would I have to do to move genesis_inpost_scripts_box from the head to the foot?
Some of the JS is adding space at the top of the screen and I'd rather deal with it rather than hiding it in a <div>
Thanks in advance,
JohnSeptember 1, 2013 at 2:57 pm #60099Gary JonesMemberMy suggestion, would be fix the source of the problem, not try and hack around it.
Have you got a URL you can share?
Why is JS adding space to the site?
WordPress Engineer, and key contributor the Genesis Framework | @GaryJ
September 1, 2013 at 3:47 pm #60104jkirkerMemberHi Gary, thanks for reaching out.
The site is currently in a development environment only accessible via VPN. ;(
The issue is that if you use Google conversion tracking code in the head it'll use a gif in the event JS isn't enabled - but it also ads a space pre-body even when you strip everything away which adds a line.
When in the footer, this isn't a big deal, but when in the header it's a problem. So I've got some scripts which I need to execute in the head and some on the foot, on a page-by-page basis.
Currently, we have a native option to add JS code to the head or the foot if we move the entire block. It'd be great if we could have the option to do either, again on a page-by-page basis.
So it doesn't look like you can directly address just the genesis_inpost_scripts_box, so I just installed a plugin which adds the functionality I needed and it's working OK - but with additional overhead.
September 1, 2013 at 4:18 pm #60107Gary JonesMemberDisable the plugin (so we can rule out any interference for the moment) and try the following in your child theme functions.php (untested):
remove_action( 'wp_head', 'genesis_header_scripts' ); add_action( 'wp_head', 'prefix_header_scripts' ); /** * Echo header scripts in to wp_head(). * * Applies <code>genesis_header_scripts</code> filter on value stored in header_scripts setting. * * Replaces <code>genesis_header_scripts()</code> so that singular scripts can be moved to the footer instead. * * @uses genesis_get_option() Get theme setting value. * @uses genesis_get_custom_field() Echo custom field value. */ function prefix_header_scripts() { echo apply_filters( 'genesis_header_scripts', genesis_get_option( 'header_scripts' ) ); } add_action( 'wp_footer', 'prefix_header_singular_scripts' ); /** * Echo singular scripts at the end of the page. * * @uses genesis_get_custom_field() Echo custom field value. */ function prefix_header_singular_scripts() { //* If singular, echo scripts from custom field if ( is_singular() ) genesis_custom_field( '_genesis_scripts' ); }
In short, that removes the Genesis function which echos both Theme Settings Header script and single entry scripts in the header, and replaces it with two function - one that puts the Theme Settings Header scripts back into the header, and the second which adds the single entry scripts into the footer instead.
I can turn this into a plugin, if you let me know that it works for you.
WordPress Engineer, and key contributor the Genesis Framework | @GaryJ
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.