Community Forums › Forums › Archived Forums › General Discussion › Trying to add some js to genesis
- This topic has 3 replies, 3 voices, and was last updated 12 years, 11 months ago by
Brad Dalton.
-
AuthorPosts
-
July 7, 2013 at 3:11 am #49607
ᴅᴀᴠɪᴅ
MemberI've bought a plugin but unfortunately it is not a 'straight out the box' wordpress plugin and needs me to manually apply it. (My first time). I am a fast learner and don't mind breaking my site a few times in the learning process either. My question is this..
The person who wrote the plugin has told me I can upload the js files into the theme folder and then "use the functions.php file to embed the js and css files relative related". Its the second bit i am confused with. Do I really need to use the functions.php file? I have read codex etc and it tells me that the code you put into functions.php is only for adding code such as
<script type='text/javascript' src='http://yourdomain.com/wp-content/plugins/yourplugin/js/custom-script.js?ver=3.3.1'></script>into my wp_head():
With Genesis i can do this from my dashboard, so do I really need to mess around with the functions.php file? Or is this always necessary when adding some js to any wordpress site?
I am trying to keep the question non-specific to this one plugin so you can help. I'm sure the process of adding any js to genesis is the same, it is just not one i am familiar with.
I love helping creative entrepreneurs build epic things with WP & Genesis.
July 7, 2013 at 3:13 am #49608ᴅᴀᴠɪᴅ
Memberjust to clarify (i tend to waffle)
I am asking if to add javascript to my genesis site, for the purpose of installing a plugin, can i insert code such as
<script type='text/javascript' src='http://yourdomain.com/wp-content/plugins/yourplugin/js/custom-script.js?ver=3.3.1'></script>into my wp_head(): through the dashboard, or do i need to insert it somehow using functions.php.
Note: I only actually need the js to load on one specific page of my site, if that changes anything.
I love helping creative entrepreneurs build epic things with WP & Genesis.
July 7, 2013 at 4:54 am #49612Stewart
MemberHi Dave,
You could insert it through the dashboard, but I advise against it for the reason that it will load on every page, thus adding unnecessary javascript for most of your site.
The way I would suggest loading it is via your functions file using a conditional tag() to only load on the specfic page you want to use your plugin on.
Hope this helps
Stewart
WordPress Developer – Need help upgrading to Genesis 2.0? – My Blog
Follow me on TwitterJuly 7, 2013 at 5:55 am #49618Brad Dalton
ParticipantUse the Scripts box below each edit page/post screen or hook it in using a custom function with conditional tag:
You'll need to save the script as a .js file and place it in a new folder in your child themes directory named js or change the path to the file in the code.
Also, use the page-slug or post/page i.d in the conditional statement.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.