0

So I noticed that I'm loading jQuery twice in my WordPress install and when I removed the CDN I added in my footer and just use the jQuery WordPress comes with my masonry stopped working and gave the error:

Uncaught TypeError: $(...).masonry is not a function.

so then I tried using wp_enqueue_script('masonry'); and wp_enqueue_script('jquery-masonry'); to load WordPress's version of masonry, it still didn't work and also the script file wasn't loaded either. I'm not sure whats going on any help would be great thanks!

6
  • Can you expand on how the two instances of jQuery are being called? – socki03 Oct 5 '17 at 15:39
  • 1
    The source of the Uncaught TypeError is because the version of jQuery included with WordPress is in noConflict mode, the object reference is jQuery, not $. – Milo Oct 5 '17 at 15:51
  • @socki03 the one i included from a cdn that i included in my footer.php, and then there was the one wordpress included in the head – jordan Oct 5 '17 at 17:18
  • @Milo ok i will try that and see if it helps – jordan Oct 5 '17 at 17:18
  • Are they both declared through the wp_enqueue_script? If the CDN one in your footer isn't, then you should look to dequeue the one from wordpress, and re-enqueue your own. – socki03 Oct 5 '17 at 17:24
1

figured it out, turns out i was missing wp_footer() in my footer, once i added that i was able to solve my problem. thanks for the help

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.