How to fix TypeError: $ is not a function in WordPress

We can guess. You purchased a theme or plugin and a console shown a message “TypeError: $ is not a function”? Ok, maybe you did not purchase anything and the TypeError was created with no reason or with manual customization. It doesn’t matter. What matters, how to fix the problem!

How can you fix the TypeError?

The first solution is to rename all references of $ to jQuery:

$( "a" ).hide(); to jQuery( "a" ).hide();

The second solution is to wrap your code using:

<script> 
jQuery(function($) {
    ...your code goes here
});
</script>

Or you can simply add to the top of the problematic .js document (or to the tag):

<script>
var $ = jQuery.noConflict();
</script>

Using of jQuery.noConflict() function causes that $ is undefined and you are probably writing in a .js document $ in a front like this:

$(document).ready(function() { });

And you should be writing this:

jQuery(document).ready(function($) {
    // your code goes here 
});

WordPress may use $ for something other than jQuery and so you need to load jQuery in a different way. 

I hope that your problem was fixed with theses solutions. If your problem persists, leave a comment and we’ll try to help you.

UNLIMITED DOWNLOADS: 50+ Million Website Templates & Design Assets

All the Website Templates you need and many other design elements, are available for a monthly subscription by subscribing to Envato Elements. The subscription costs $16.50 per month and gives you unlimited access to a massive and growing library of over 50 million items that can be downloaded as often as you need (stock photos too)!

Recent Articles

How to Change WordPress Theme If It Does Not Work (No Access to wp-admin) Through phpMyAdmin

Something is wrong. Your WordPress theme has got a blank screen and you can not log in to your admin through /wp-admin/...

How to Bulk Deactivate WordPress Plugins (No Access to WP-Admin) Through phpMyAdmin

Sometimes happens that you don't have any backups of your WordPress site (ups) and after your plugins update nothing works (ups, twice!),...

Landco – Garden & Landscaping WordPress Theme [Free WordPress theme download]

Demo Download Landco – Garden & Landscaping WordPress Theme Landco – Garden & Landscaping...

Optrica – Optometrist & Eye Care WordPress Theme [Free WordPress theme download]

Demo Download Optrica – A Premium WordPress Theme for all kind of optometrist...

Qwery – Multi-Purpose Business WordPress Theme + RTL [Free WordPress theme download]

Demo Download Giant Multi-Purpose Business Elementor WordPress Theme v1.0.4 Qwery is an innovative responsive...

Get in touch

Be our first-class reader, build a community and follow us on social media!

Leave A Reply

Please enter your comment!
Please enter your name here