0

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.

  • what do you mean by "does not work"? do you see errors in the browser's javascript console? – Milo Jan 2 '17 at 22:13
  • What are you trying to write in jquery? And how are you enqueueing it? Jquery is automatically installed in wordpress. – Chess Byte Jan 2 '17 at 22:17
  • Where you've added this ? At footer or header ? Before other scripts ? – CodeMascot Jan 3 '17 at 3:25
1

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');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.