

We could simply enqueue it, but then there would be two copies/versions of jQuery loaded on the page (yours and WP’s). Now, let’s say that we want to use a version of jQuery that is different than the one that is included with WordPress. The codex entry for wpregisterscript tells you the default values - just pass those. While deps is optional, you need to provide it if you want to specify a subsequent parameter. So when we declare our custom script, we set the $deps parameter equal to array('jquery') and call it a day. 1 It looks like you're passing true in the wrong place - WordPress will interpret that as the value for deps. Wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer )

For reference, here are the parameters used for wp_enqueue_script(): This declares jQuery as a dependency for my-custom-script, so WordPress automatically will load its own copy of jQuery. wpenqueuescript ( 'ajax-products', pluginsurl ( '/js/ajax.js', FILE ), array ('jquery'), '1.2', false ) You can use pluginsurl () with the second parameter of FILE to get the directory of the specific pluign, and in the first argument you pass the relative location of your script. '/js/my-custom-script.js', array('jquery'), null, true) Don’t worry about being fluent in PHP programming the information you need for this lesson is provided. Enqueueing is used for both scripts and styles and means we must access and alter the functions.php file that comes with your WordPress installation. The smart loading requires that you specify jquery as the $deps parameter when enqueuing your other JavaScript files, for example: wp_enqueue_script('my-custom-script', get_template_directory_uri(). The method for adding your own scripts and styles to your theme is called enqueueing. These days, WordPress automatically loads jQuery for you, whenever some other script requires it. Much has changed with WP script loading since this article was posted. How was your plugin to know you already had it loaded? For one thing, some plugins use the jQuery library, and they are going to load it as well.
#Wordpress enqueue script in header download
If you want, you can just download jQuery, put it on your server and link to it from your header.php file in the section.
