JQuery plugin that works with Google 1.10.2 and not with WordPress 1.10.2

I’m making a custom implementation of JQuery Colorbox in a WordPress plugin. However, it’s not working with my default WordPress installation. After tinkering a bit, it comes down to the inclusion of the JQuery library.

Neither of these lines work:

Read More

<script src='http://xpisobsolete.com/wp-includes/js/jquery/jquery.js?ver=1.10.2'></script>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

But either one of these do:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

I’ve tested that JQuery works with all of the above by using:

if (typeof jQuery != 'undefined') {

    alert("jQuery library is loaded!");

}else{

    alert("jQuery library is not found!");

}

It passes on all four of the script links I’ve tried. If I change that one line on Jack’s demo page, it breaks as well. Is this a colorbox issue?
http://www.jacklmoore.com/colorbox/example1/

Could you guys help me see what I’m missing here? I’m stumped.

Related posts

1 comment

  1. Try placing your code in this

    (function($) {
        // Inside of this function, $() will work as an alias for jQuery()
        // and other libraries also using $ will not be accessible under this shortcut
    })(jQuery);
    

    I’m suspecting your code uses $, which is normally an alias for jQuery but doesn’t work globally because WP’s version of jQuery is in no conflict mode. $ will work if the code is placed in an enclosure such as the one above.

Comments are closed.