WordPress issue : “$ is not a function”

 

Don't freak out, it's easy to fix. When trying to add a jQuery accordion script to a wordpress template I came across this firebug error. “$ is not a function”. Simple enough to fix, just convert all the "$'s" to "jQuery" within the script and you should be good to go.

For example:

$(document).ready(function() {
	//ACCORDION BUTTON ACTION (ON CLICK DO THE FOLLOWING)
	$('.accordionButton').click(function() {
		//REMOVE THE ON CLASS FROM ALL BUTTONS
		$('.accordionButton').removeClass('on');
		//NO MATTER WHAT WE CLOSE ALL OPEN SLIDES
	 	$('.accordionContent').slideUp('normal');
Would be changed to :
jQuery(document).ready(function() {
	//ACCORDION BUTTON ACTION (ON CLICK DO THE FOLLOWING)
	jQuery('.accordionButton').click(function() {
		//REMOVE THE ON CLASS FROM ALL BUTTONS
		jQuery('.accordionButton').removeClass('on');
		//NO MATTER WHAT WE CLOSE ALL OPEN SLIDES
	 	jQuery('.accordionContent').slideUp('normal');
I've replaced the $'s with jQuery and it works fine.
Go give it a try!
Share
This entry was posted in jQuery, Web Development, Wordpress and tagged , . Bookmark the permalink.