How do you install jQuery in WordPress?

How can I install jQuery on my WordPress site?

Related posts

Leave a Reply

2 comments

  1. 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!

  2. Jquery Already packaged with the WordPress installation, and gets available with it.
    Check the source code when you get your new WordPress Blog installed.