Call Us Today! (866) 377-4331 or Request a Quote

wp_enqueue_script(), jQuery, and WordPress

jQuery and WordPress

A quick note on using jQuery with WordPress for those having any trouble with it. I decided to use wp_enqueue_script() to include the jQuery library in a recent project and discovered the jQuery code wouldn’t do anything.

After a bit of searching, I discovered the solution was to replace all the “$()” in my jQuery code with “jQuery()”.

Apparently, in order to prevent collisions with the Prototype javascript framework, which also uses “$()”, you have to use jQuery() instead of $() for all your jQuery functions to work with wp_eneque_script().

5 Comments
  1. Hi John,

    Can you tell me how you implement your "Sign up for IntenseDebate" ?
    I tried with subscribe2 but doesn't work (you can have a look on my website, the ceheckbox is faraway from the text…)

    Thanks for you work again !

    Seb

  2. If you mean the link below the comments section that says "Sign up for IntenseDebate", that's added by default when you install the IntenseDebate comment system. Hope that answers your question.

  3. How do you include the
    tag into the site. Does it go in a header or in the <script src=”
    “> ??? I’m a bit lost….one of those whom you say is having trouble trying to include jQuery

  4. Hey, I noticed my site is loading 3 jquery.js scripts… I think from three different plugins? Two are the version included with wp (1.2.6) and another is more recent.

    Any idea how to keep jquery from being called in the header twice? (and third time from other plugin)?

  5. Thanks for this invaluable tip – it saved me going bald from further hair pulling!