Forums

Installing Jquery sripts into wordpress (15 posts)

  1. ravalde
    Member
    Posted 9 months ago #

    Hi can anyone point me to a tutorial on how to include jquery scripts I have tried the code below in my function.php but it doesn't work.

    [Code moderated as per the Forum Rules. Please use the pastebin]

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 9 months ago #

    I think they need to be registered to be enqueued....

    http://codex.wordpress.org/Function_Reference/wp_register_script

  3. ravalde
    Member
    Posted 9 months ago #

    How do i use pastebin I've copied my code into it but where do I connect it to my post

  4. ravalde
    Member
    Posted 9 months ago #

    Sorry link to my code is below. I have placed all my assets and images in the root of my testsite child theme Im working in twenty eleven.

    These are the jquery scripts that came with the slider.
    jquery-1.6.1.min.js
    jquery-ui-1.8.10.custom.min.js
    jquery.wt-lightbox.js
    jquery.wt-lightbox.min.js
    jquery.wt-scroller.js
    jquery.wt-scroller.min.js
    slider.js

    This is in my functions.php to enque the scripts
    http://pastebin.com/ULL7S2pW

    This is slider.js and is in my js folder at the root of my child theme
    http://pastebin.com/yssKsETj

    this is the link to the plugin page
    http://codecanyon.net/item/jquery-horizontal-image-scroller-w-lightbox/112734

  5. ravalde
    Member
    Posted 9 months ago #

    RE: see above

  6. ravalde
    Member
    Posted 9 months ago #

    Thanks not sure if thats the problem I love this scroller just cant seem to get it to work in wordpress the guy who created it says its easy to install in WP beats me what I'm doing wrong.

  7. Jackson
    Member
    Posted 9 months ago #

    This would be much easier to troubleshoot with a link to the test site.

    You should also look at this: http://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/ for information on using jQuery in WordPress using a noConflict wrapper to avoid trouble, and not using the '$' shortcut.

  8. ravalde
    Member
    Posted 9 months ago #

    Thanks (Jackson)

    Think I've tried that method think I'll try and find a plugin but so far found nothing similar to the codecanyon scroller above that's avaailable.

  9. vjpo
    Member
    Posted 9 months ago #

    I don't know exactly what is affecting your script.
    Try
    wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js' );
    it will load script to the header (now it's loading to the footer)

    add array('jquery') to all wp_enqueue_script functions that loading jQuery scripts, e.g.
    wp_enqueue_script('lightbox', get_bloginfo('template_directory').'/js/wt-lightbox.min.js', array('jquery'));

    The last one - may be it doesn't work because of jQuery version - try to change version to 1.4.2 to check it.

    Links to tutorials in the "Resources" section on this page
    http://codex.wordpress.org/Function_Reference/wp_enqueue_script

  10. ravalde
    Member
    Posted 8 months ago #

    Hi vjpo thanks for the advice, can i ask when you say "(now it's loading to the footer)" do you literaly mean this is happening or is this an instruction to load from the footer, ...Thanks

  11. vjpo
    Member
    Posted 8 months ago #

    the code from your functions.php pastebin example
    wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js', false, '1.6.1', true);
    true at the end of string places js script to the footer $in_footer = true

    <?php wp_register_script( $handle, $src, $deps, $ver, $in_footer ); ?>
    http://codex.wordpress.org/Function_Reference/wp_register_script

    But, by the way, did you resolve the issue?

  12. ravalde
    Member
    Posted 8 months ago #

    No - thanks for the advice still cant get it to work I think with all the hassle related to this scroller, I think I'll try to find a plugin that is similar just havn't found one that works yet

    http://codecanyon.net/item/jquery-horizontal-image-scroller-w-lightbox/112734

  13. vjpo
    Member
    Posted 8 months ago #

    try to load your slider.js (second pastebin example) by this way.
    Add this code to your functions.php

    // Load Dom Ready Javascripts
    function load_scroller_js() { ?>
    <script type="text/javascript">
        jQuery(document).ready(function($) {
        //initialize scroller
        // full scroller script here
    </script>
    <?php }
    add_action('wp_head', 'load_scroller_js');

    and exclude same script from the enqueue list

  14. ravalde
    Member
    Posted 8 months ago #

    Thanks again vjpo still cant get it to work - works in the html example I downloaded - I'll leave it and find a plugin - found one thats 90% there just judders every now and then it's an iframe example here's the link if anyone needs it

    http://www.gopiplus.com/work/2011/07/24/wordpress-plugin-wp-iframe-images-gallery/

  15. ravalde
    Member
    Posted 8 months ago #

    maybe I need to include something like this that targets the child theme

    add_action('get_header', 'metric_load_scripts');
    function metric_load_scripts() {
    wp_enqueue_script('follow', CHILD_URL.'/lib/js/follow.js', array('jquery'),'1',TRUE);
    }

Reply

You must log in to post.

About this Topic