Skip to:
Content
Pages
Categories
Search
Top
Bottom

JQuery Issues


  • absticles
    Participant

    @absticles

    Hey there.

    I’m a newbie to Buddypress and I’m developing a child theme for it.

    I’m having some issues with JQuery. I’m trying to create a simple slideshow using the help from this tutorial http://www.deadmarshes.com/Blog/jQuery%20Slideshow.html but I can’t seem to get the JS to work!

    In my header.php file I’ve tried every type of script I can think of. Currenty I have the jQuery file in MYTHEME_incjsjquery.js and in my header.php file I have the script location as php bloginfo(‘template_directory’) /_inc/js/jquery.js">
    I’ve tried ‘template_url’ and ‘stylesheet_directory’ and neither of those work either. I’ve also deactivated other plugins to see if there was a JavaScript conflict but no such luck. Not really sure where I’m going wrong!

    Hope someone can help!

    Thanks.
    Abi

Viewing 7 replies - 1 through 7 (of 7 total)

  • absticles
    Participant

    @absticles

    Ps. I know that php code is wrong, I just don’t know how to display code in these forums!


    absticles
    Participant

    @absticles

    Can anyone help with this? Sorry, it’s probably a really simple solution!


    Boone Gorges
    Keymaster

    @boonebgorges

    Is your problem that the javascript isn’t loading?

    The best way to include the script is with https://codex.wordpress.org/Function_Reference/wp_enqueue_script.

    You could also just edit the header.php file of your theme to include a script tag.

    add this to functions.php

    function my_init() {
    if (!is_admin()) {
    wp_deregister_script(‘jquery’);
    // load the local copy of jQuery in the footer
    // wp_register_script(‘jquery’, ‘/wp-includes/js/jquery/jquery.js’, false, ‘1.3.2’, true);
    // or load the Google API copy in the footer
    // wp_register_script(‘jquery’, ‘http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js’, false, ‘1.4.2’, true);

    wp_enqueue_script(‘jquery’);
    }
    }
    add_action(‘init’, ‘my_init’);

    comment out which one you want to use, then add ur jquery code to the footer.php above wp_footer();
    best way to load jquery is in the footer for faster page loading


    absticles
    Participant

    @absticles

    Thanks so much for your help! I really appreciate it.

    I’ve added that code to my functions.php file. Which bit of the code do you mean when you suggest to place my jQuery code into the footer? If you mean the whole div element which requires the jQuery that won’t work because it would move the div to a new part of the page?

    Thanks in advance. This has been driving me crazy all day!

    Abi

    put your jquery code in the footer.php file, not the div…
    for example:
    script type=”text/javascript” src=”wherever the jquery plugin file is” /script
    script type=”text/javascript”
    jQuery(document).ready(function($){
    your code
    });
    /script

    ryt above wp_footer();
    i have left out < in the script part above coz these forums wont allow code argh! lol


    absticles
    Participant

    @absticles

    Thanks so much for your help! I’ll be honest, I couldn’t get what you suggested to work. I must have put something in the wrong place!

    But after fiddling with the script src’s in the header it suddenly started working. Weird!

    Thanks anyway pal!
    Abi

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘JQuery Issues’ is closed to new replies.
Skip to toolbar