Grow your CSS skills. Land your dream job.

jquery and WordPress

  • # June 9, 2009 at 2:59 pm

    Hi.
    I have been trying to get jquery to work on my custom worpdress theme and i cant get it to work..
    I know you have to use the wp_enqueue_script() to call the jquery library and to replace the $()”, with jQuery() .

    Im trying to get an image slider to show some of my work on and it just wont work..

    Anyone have any ideas? Or any good sites with info/tutorials on?

    Thanks,

    Joe

    # June 9, 2009 at 6:49 pm

    I usually just stick my scripts in header.php. wp_enqueue_script is too fiddly.

    Code:
    Rob
    # June 9, 2009 at 6:51 pm

    dave does it my way…. lol

    # June 10, 2009 at 11:52 am

    Maybe i’m wrong but as far as i know jQuery is already "included" bij WordPress so it’s already declared.

    I had problems with a slider jquery library. And I solved it by putting the wp_enqueue_script in the header just before wp_head and the script itself just below wp_head.

    I have no idea why but that was the only way i got it working

    Rob
    # June 13, 2009 at 5:12 am

    yup a recent lib version is included, although im not sure if you need to add it to your head or if its done for you :)

    # June 13, 2009 at 11:53 am

    Hi..
    Thanks you for getting back to me..
    Ill keep trying and let you know if the above works!

    # June 13, 2009 at 12:52 pm

    I always use the google hosted version of jQuery.

    Here is a screencast about building a jQuery slider into WordPress http://blog.themeforest.net/wordpress/wordpress-for-designers-day-15/

    # September 23, 2009 at 5:03 pm

    I had a problem getting a smooth scroll effect using jQuery to work, and eventually found a fix that worked:

    Code:
    jQuery.noConflict();

    // Put all your code in your document ready area
    jQuery(document).ready(function($){
    // Do jQuery stuff using $

    $.localScroll();
    $.localScroll.hash()

    });

    Whereas $.localScroll() and $.localScroll.hash() activate the scrolly effect everywhere on the page.

    However I think .noConflict() can cause some conflicts with other libraries with $ object models, so be careful! If someone could enlighten me to why that is or if there’s a better way than .noConflict(), let me know at http://twitter.com/WebDojo.

    So in the end I used a plugin called HeadSpace to include my localScroll and scrollTo files, and a last file I named smooth-scroll-activate.js that included the code you see above.

    And voila! Drunken pirate coding.

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

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".