How can I install jQuery on my Wordpress site?
-
You don't install jquery, you merely include the library and start using it. – Brad Apr 25 '11 at 05:32
-
did you try to search for an answer? – austinbv Apr 25 '11 at 05:32
-
possible duplicate of [jQuery and Wordpress](http://stackoverflow.com/questions/788071/jquery-and-wordpress) – Blender Apr 25 '11 at 05:33
-
@Blender. I want to add some effects on my site using jQuery. – johan Apr 25 '11 at 05:39
-
3Just a note. WP already uses jQuery so you just need to put `wp_enqueue_script("jquery"); ` in your `` – JohnP Apr 25 '11 at 05:47
2 Answers
Though one of the Answer is already Accepted but I feel the following technique may help somebody.
Include the following code at Plugin Page
OR at function.php
function include_jQuery() {
if (!is_admin()) {
wp_enqueue_script('jquery');
}
}
add_action('init', 'include_jQuery');
Definitely you can use any meaningful function name instead off include_jQuery
.
Alternately, you can use the following code:
function include_jQuery() {
if (!is_admin()) {
// comment out the next two lines to load the local copy of jQuery
wp_deregister_script('jquery');
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js', false, '1.8.3');
wp_enqueue_script('jquery');
}
}
add_action('init', 'include_jQuery');
Finally, as a general rule, you should not use the $
variable for jQuery
unless you have used one of the shortcuts. The following is an example of how to shortcut jQuery to safely use the $
variable:
jQuery(function ($) {
/* You can safely use $ in this code block to reference jQuery */
});
You may like THIS link as well from where I personally learn the above technique(s). A Very BIG Thanks to Ericm Martin!

- 1,179
- 1
- 10
- 24
Jquery Already packaged with the Wordpress installation, and gets available with it. Check the source code when you get your new Wordpress Blog installed.

- 2,987
- 16
- 58
- 106