sheriffderek
sheriffderek

Reputation: 9053

jquery cycle plug in not translating to wordpress

I have a working website that i am translating over to a WordPress theme. jquery.cycle.js works great. However I can't seem to get it working in WordPress.

  1. call jquery (already called in WP)

  2. call cycle.js (registered, enqueued, and seems printed out as it should when viewing source.

  3. have the little script in the head

    $(document).ready(function() {
        $('.slideshow').cycle({
            fx: 'fade' 
        });
    });
    

I have also tried putting this in it's own .js --- but no luck with that yet....

Have a little img list holding place from the cycle demo.... in a div with the class .slideshow

Everything works fine in the original HTML layout. So I just keep going over this list...

All of the things show up in WordPress when I view source. anyways. none of my jquery stuff is working. I think that if I can get some help with this one thing... it will explain what I am doing wrong.

Getting this... so I guess some of my scripts are using $ and some jQuery --- gotta get some unity going on here...

enter image description here

http://www.pauljoyceuk.com/codex/2011/jquery-is-not-a-function/

SO found this...

$(document).ready(function() {

change to

jQuery(document).ready(function() {

this is easy enough with small files...

but what about big files...

jQuery(document).ready(function( $ ) {

if you pass the $ ---- then eveything seem to work great - without having to change all of them... however - now even though things seem great... I have a whole new host of crazy Errors... hmmm

Upvotes: 0

Views: 215

Answers (1)

JKirchartz
JKirchartz

Reputation: 18042

Wordpress's packaged jQuery defaults to noConflict mode, use jQuery('document'), or wrap your code like

(function($) { 
    // Code that uses jQuery's $ can follow here.
})(jQuery);

or in your document ready like this:

jQuery(document).ready(function($) {
    // Code that uses jQuery's $ can follow here.
});

Upvotes: 1

Related Questions