18 Aug 2009

WordPress & jQuery: “$ is not a function”

jQuery, Wordpress 116 Comments

If you are trying to add your own jQuery code to WordPress, and have had the error “$ is not a function” show up on Firebug, here is the fix:

Convert all dollar signs ($) to ‘jQuery’

The dollar sign is reserved in WordPress for the Prototype library, which is why it errors out. For example, instead of:

$().ready(function() {
   $("#select_me").show();
});

Change it to:

jQuery().ready(function() {
   jQuery("#select_me").show();
});

116 Responses to “WordPress & jQuery: “$ is not a function””

  1. litle rangda says:

    lol….
    Thanks alot.
    I change $ -> $$
    Because when I used jQuery appear “is not a function”.

    BR,
    little rangda

  2. Payson Welch says:

    Thanks this saved me a ton of time and worked fine, didn’t have to use $$ like the other commenter suggested.

  3. Gabriel Crowe says:

    dont both with this lot. do it like this:

    (function($) {
    // your code with dollars here
    })( jQuery );

    enclose your code in this type of structure.

  4. Ali shahbaz says:

    thanks too much..

  5. Andy Feliciotti says:

    This saved me some hassle, thanks mate!

  6. Gita says:

    Thank you so much this saved my time:)

  7. cem says:

    thank you

  8. Sue says:

    Thanks.

  9. Husain Ali says:

    Thanx a lot

  10. Mahesh says:

    Many many thanks.

  11. Edward Beckett says:

    @Gabriel … good call … all the scripts using that construct work fine …

  12. Juni says:

    GRACIAS this was killing me!!

  13. Gautam Doddamani says:

    thanks a ton dude i was tweaking my code for a long tym coz of this error… in previous wordpress versions it was working out fine but since the 3.3 and 4 i was getting this error in firebug and chrome inspector..jslint also couldnt solve this lol :D

  14. Joel says:

    The thumbnails stopped working after updating to WordPress 3.4. I edited the script by replacing the $ with jQuery. The thumbnails work! Many thanks!

  15. Ivo Casqueira says:

    Thanks a lot man. I was struggling with the darn code and with all i could think of… when in the end it was just this small thing… -_-’ lol Thank you a lot :)

  16. Nikhil says:

    Thanks,

Leave a Reply