TypeError: $ is not a function WordPress
You use jQuery.noConflict();
So $
is undefined.
You can read more about it here docs
Try to modify your code in this way (add $
sign to ready function):
jQuery(document).ready(function($) { // Code that uses jQuery's $ can follow here.});
Function errors are a common thing in almost all content management systems and there is a few ways you can approach this.
Wrap your code using:
<script> jQuery(function($) {YOUR CODE GOES HERE});</script>
You can also use jQuery's API using
noConflict();
<script>$.noConflict();jQuery( document ).ready(function( $ ) {// Code that uses jQuery's $ can follow here.});// Code that uses other library's $ can follow here.</script>
Another example of using noConflict without using document ready:
<script>jQuery.noConflict(); (function( $ ) { $(function() { // YOUR CODE HERE }); });</script>
You could even choose to create your very alias to avoid conflicts like so:
var jExample = jQuery.noConflict();// Do something with jQueryjExample( "div p" ).hide();
Yet another longer solution is to rename all referances of $ to jQuery:
$( "div p" ).hide();
tojQuery( "div p" ).hide();
Instead of doing this:
$(document).ready(function() { });
You should be doing this:
jQuery(document).ready(function($) { // your code goes here});
This is because WordPress may use $ for something other than jQuery, in the future, or now, and so you need to load jQuery in a way that the $ can be used only in a jQuery document ready callback.