Code Snippets Gallery
Include jQuery in WordPress Theme
The following is the best way to go about it. Add the following to the theme’s functions.php file:
if( !is_admin()){
wp_deregister_script('jquery');
wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"), false, '1.3.2');
wp_enqueue_script('jquery');
}Replace the URL with the location of what version of jQuery you want to use. The URL above (at the time of this writing) links to the latest version of jQuery on Google’s servers (v1.4) and has in the past linked to v1.3.2. Theoretically I would think it will continue to be the most latest version, until jQuery goes 2.0.
Why is this the best method? What is the difference between this method and simply referencing it like
<script type="text/javascript" src="/js/jquery-1.3.2.min.js">Buddy, this one is to avoid Jquery conflicts i reckon.
I believe it’s because jquery will download faster from googleapis, which is on many servers, than just the one your site is on.
Thanks for Your JQuery Tutorial
It’s really helpful for me.
Thanks a lot
This needs to be updated to jQuery 1.4.0 by changing that call specifically
So simple. So perfect. Thanks!
thanks ı will try it .
I can´t get jQuery to work with wordpress, I’ve been trying so many different things. Can you please look at my code, and see what’s wrong?
$(document).ready(function() {
$(‘.slideshow’).cycle({
fx: ‘fade’ // choose your transition type, ex: fade, scrollUp, shuffle, etc…
});
});
Sorry, my code was clipped…
?php wp_enqueue_script(‘jquery’); ?>
?php wp_enqueue_script(‘jquery-ui-1.8.2.custom.min’, ‘/wp-content/themes/nordborg/js/jquery-ui-1.8.2.custom.min.js’,array(‘jquery’)); ?>
?php wp_enqueue_script(‘jquery.cycle.min.js’, ‘/wp-content/themes/nordborg/js/jquery.cycle.min.js’,array(‘jquery’)); ?>