I do not manually add any jQuery files.
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js'></script>
This way, it does not work as it is on the page.
How can I resolve it?
Thanks.
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI do not manually add any jQuery files.
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js'></script>
This way, it does not work as it is on the page.
How can I resolve it?
Thanks.
Don't load jQuery that way. It comes built into WordPress, so what you really want to do is tell WordPress that (1) your Javascript file should be loaded, and (2) it relies on jQuery being loaded. You do this with wp_enqueue_script.
So put this in your functions.php file, replacing the path in quotes with the path to your (jQuery-dependent) Javascript file in your theme:
function my_jquery_script () {
wp_enqueue_script ('my-jquery-script', get_template_directory_uri () . '/js/my-jquery-script.js', ['jquery'], '1.0', true);
}
add_action ('wp_enqueue_scripts', 'my_jquery_script');