Why can't we use "$" instead if jQuery in wordpress? Usually "$" is the alternative of jQuery right? But in Wordpress it shows "$" is not a function. I dont get why is that so. Can anyone explain?
3 Answers
Have a look at tip 5 in this web page: 5 Tips for using jquery with wordpress:
It is important to know that the version of jQuery that comes with WordPress automatically calls the jQuery.noConflict(); function, which gives control of the $ variable back to whichever library first implemented it. If you are loading a different copy of jQuery, you'll need to manually call jQuery.noConflict();, if necessary, from one of your JavaScript files.
I hope that helps.

- 2,981
- 1
- 29
- 35
-
2You can also do something like this: `jQuery(document).ready(function ($) { $('myobject').html(); }` – akahunahi May 14 '14 at 19:26
The tricky thing is this particular copy of jQuery is in compatibility mode by default. That means that the typical ‘$’ shortcut for jQuery doesn’t work, so it doesn’t conflict with any other JavaScript libraries that use the dollar sign also, like MooTools or Prototype.

- 38,346
- 37
- 130
- 192
-
I found the mention of compatibility mode and the implication that perhaps a different version of jQuery would allow the $ shortcut to be used. Every post on this issue I have seen ends with somebody saying "Just replace $ in your script with 'jQuery'" ... what what if we want to use the shortcut? This seems to be the operable question in my mind. I've seen this apply to WordPress a lot, but my situation is CDN: http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js – Eric Hepperle - CodeSlayer2010 Jun 29 '14 at 06:22
jQuery(...)
should be used instead of $(...)
Edit ----
sorry, i misread your question.
It depends on the jquery implementation of your wordpress version.
I have seen wordpress sites that allowed the usage of $
before, but i don't really know what it depends on.

- 1,746
- 3
- 23
- 37