More

    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.

    Recent Articles

    How to remove category & tag base from WordPress URL

    Would you like to remove the category & tag base from WordPress URL? Do you need custom URL's? It's a super simple!...

    How to Disable Right Click on WordPress

    Are you worried about having your images stolen from your WordPress website? Then you need to know how to disable right click on...

    How to redirect HTTP to HTTPs in .htaccess

    Today's standard is to have an https certificate. Google will love you if your sites are secured. So https is not standard,...

    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,...

    How to fix Unknown collation: ‘utf8mb4_unicode_520_ci’

    Unknown collation is probably caused because your local and live server are running different versions of MySQL. This problem mostly comes when...

    Related Stories

    Leave A Reply

    Please enter your comment!
    Please enter your name here

    Stay on op - Get the daily news in your inbox