Lego2012
12/13/2016 - 10:57 AM

Include jQuery in WordPress Theme

Include jQuery in WordPress Theme

<!-- http://digwp.com/2009/06/use-google-hosted-javascript-libraries-still-the-right-way/ -->

<!-- The following is the best way to go about it. Add the following to the theme's functions.php file: -->

if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);
function my_jquery_enqueue() {
   wp_deregister_script('jquery');
   wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", false, null);
   wp_enqueue_script('jquery');
}

<!-- Replace the URL with the location of what version of jQuery you want to use. -->