Trying to add some js to genesis

Community Forums Forums General Discussion Trying to add some js to genesis

This topic is: not resolved

This topic contains 3 replies, has 3 voices, and was last updated by  braddalton 1 year, 3 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #49607

    David Browne
    Participant
    Post count: 167

    I’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.


    We are Dave & Erin. Full time travellers and designers. Currently in Sydney. Follow us on Google +. I’m new to twitter so be the first to say hey Twitter

    Note: Known to give only give negative critique on design. I don’t mean to offend anybody, it is just more efficient pointing out mistakes than saying “yes, its beautiful” every time. :)

    #49608

    David Browne
    Participant
    Post count: 167

    just 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.


    We are Dave & Erin. Full time travellers and designers. Currently in Sydney. Follow us on Google +. I’m new to twitter so be the first to say hey Twitter

    Note: Known to give only give negative critique on design. I don’t mean to offend anybody, it is just more efficient pointing out mistakes than saying “yes, its beautiful” every time. :)

    #49612

    Stewart
    Participant
    Post count: 156

    Hi 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 Twitter

    #49618

    braddalton
    Participant
    Post count: 10355

    Use 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.


Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.