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

How to bulk delete WordPress comments in PHPMyAdmin

Any user working on the computer system has the option in quickly deleting all the WordPress comments by using MySQL or phpMyAdmin....

Removing unwanted p and br tags from WordPress

When working with HTML, you sometimes don’t like your HTML editors because of the irritating automatic bugs. Yes, we are here with...

The 7 Best WordPress Plugins For Google Analytics 2020

As the saying goes, "what is not measured, is not managed." After setting up a WordPress website, it’s important to see what’s...

How to hide all WordPress update notifications in dashboard

When working on a project, it can be frustrating to have to deal with all the update notifications that are in the...

How to add custom HTML to wp_nav_menu

WordPress has a lot of features that help us solve almost all daily tasks of any programmer or web developer. Due to...

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