0

as the title suggests, I am running into this annoying issue:

The search is not working in wordpress but it is working in the fiddle and locally.

The sorting is working in wordpress.

I have the jquery load script in wordpress post body:

https://jsfiddle.net/ncxv16eL/

What am I missing?

2
  • Is your scripts included in the post? Commented Jan 6, 2016 at 2:54
  • yes because the search script and the sort script are 1 file and the sorting works. Commented Jan 6, 2016 at 2:56

3 Answers 3

0

I was loading jQuery after loading script like this:

<script src="myscript.js" type="text/javascript"></script>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 

It needs to be jQuery on top.

0

You should be using the wp_enqueue_script method to handle this, you can set dependencies that will address this exact issue by making sure that jQuery is loaded before your script.

Also, WordPress ships with jQuery - is there a reason your loading an external copy?

0

You don't have to include jquery manually. Wordpress is shipped with jquery. You should take a look at wp_enqueue_script() to get familiar with scripts inclusion in your site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.