I am pretty new to WordPress and I am figuring out how to include jQuery into a theme.
I create the following function into functions.php theme:
function load_java_scripts() {
// Load FlexSlider JavaScript that handle the SlideShow:
wp_enqueue_script('jQuery-js', 'http://code.jquery.com/jquery.js', array(), '1.0', true);
}
add_action('wp_enqueue_scripts', 'load_java_scripts');
So I think that I can add it as some other JavaScript or CSS local resources but I am not sure about this method because in this case the jquery.js is not a local resource but is an online resource (is it the same thing?)
I also have some doubts because searching online I have found different methods to add jQuery to my theme, like this one.
Can you give me some information about how to correctly complete this task?
Is there any specific reason why you’re not using the jQuery found in WordPress?
If you need to add your JavaScript file which depends on jQuery, you can add jQuery as a dependency.
Note that WordPress loads jQuery in no conflict wrappers. so your code should be like:
Since WP already comes with jQuery, I would simply load it for your theme, add it like this into your functions.php
There are several ways to include jQuery into a theme. I always use WP bundled version which I find very simple.
In wordpress No need for Custom Jquery.
Add dependencies as ‘jquery’ it’ll automatically get loaded.
try this,
You can use the methods below to include jQuery: