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:

jQuery(function($) {
    ...your code goes here

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

var $ = jQuery.noConflict();

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.

Recent Articles

Why is WordPress Asking For Your FTP Credentials to Install Plugins?

You want to install any plugin, but *blink* - WordPress need your FTP credentials. What the hell? The problem is simple -...

Fix PHP Warning: POST Content-Length of 8978294 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

This error is getting probably when you trying to upload an import on WordPress on your XAMPP local dev environment, right? Well,...

How to Hide Shipping Methods in WooCommerce?

This is a small detail, but WooCommerce doesn't have built-in any function for hiding shipping methods based on different situations. Imagine when...

How to Get WordPress Post Featured Image URL

Are you a WordPress developer or an advanced WordPress user? Whoever you are, sometimes you may need the direct URL of a...

How to Bulk Delete Media in WordPress

WordPress and media. That's the topic for a book. Sometimes is not easy to find what you need and when you have...

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