homepage Welcome to WebmasterWorld Guest from 54.237.78.165
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / WordPress
Forum Library, Charter, Moderators: lorax & rogerd

WordPress Forum

    
Add javascript to template in Genesis
wilkinsj



 
Msg#: 4694444 posted 9:37 pm on Aug 10, 2014 (gmt 0)

Hi everyone

I need to add a piece of javascript code to all of the pages using a certain template. My site is running on the Genesis framework. Any idea how to do this?

Many thanks in advance
V

 

Planet13

WebmasterWorld Senior Member planet13 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4694444 posted 4:09 pm on Aug 11, 2014 (gmt 0)

Firstly, did you go to the studiopress support forums and ask this yet?

[studiopress.com...]

Secondly, do you really mean template? Or do you really mean layout?

I am guessing you mean layout (and I apologize if I guessed wrong). There is a conditional for displaying which layout is being used:

genesis_site_layout();

So if you know the name of the layout, you could do a conditional to show the javascript.

You might try something like this:

WARNING: I AM A TERRIBLE PHP CODER. USING THE FOLLOWING CODE MIGHT JENK YOUR WHOLE SITE. YOU HAVE BEEN WARNED:

<?php
$site_layout = genesis_site_layout();
if ( 'LAYOUT-NAME-HERE' == $site_layout ) {
?>

[JAVASCRIPT GOES HERE]

<?php } ?>



Again, I pull most of my php code out of my keister, and I am far too lazy to google it and see if it is the right format or not, so USE AT YOUR OWN RISK.

Chances are it is probably missing a ; or something like that somewhere.

Whatev.

I would also install the genesis simple hooks plugin so that it is easy to install this code into your template.

You might get an idea on how to do it correctly from the place where I stole this code, namely:

[billerickson.net...]

Hope this helps.

lorax

WebmasterWorld Administrator lorax us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4694444 posted 2:01 pm on Aug 12, 2014 (gmt 0)

I believe the Genesis themes provide a way to add custom code to the framework via the admin interface. Look for an option called Header/Footer Scripts.

Planet13

WebmasterWorld Senior Member planet13 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4694444 posted 6:48 pm on Aug 21, 2014 (gmt 0)

I believe the Genesis themes provide a way to add custom code to the framework via the admin interface. Look for an option called Header/Footer Scripts.


Yes, they do allow you to call various scripts in the header and footer areas.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / WordPress
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved