jQuery in WordPress: wp_enqueue_script
Did anybody notice the new sitemap I did for the blog? Top-right, in the black part. Click on sitemap. Smooth! For those of you who don’t know, that’s jQuery. Okay, seriously, this is my first ever jQuery script because I love Prototype. I don’t know why I did that, since I could have done it with Scriptaculous. So, about scripts in WordPress… You all heard about the function wp_enqueue_script in WordPress, yeah it’s cool, but what if I want to use both Prototype AND jQuery? Yeah, sounds stupid, but what about having two different plugins installed. One that uses Prototype, the second one jQuery. Compatibility?
Took me quite some time to figure out how to use jQuery $() function in WordPress though. I really think that the man who came up with this is a genius. There’s a synonym for the $() function in jQuery called jQuery(). WordPress’ers must have removed the $() function for Prototype compatibility.
jQuery(document).ready(function(){
jQuery(".sitemap-click").click(function(){
jQuery("#sitemap").fadeIn("slow");
return false;
});
});
So instead of $() we use jQuery(). Sweet.
Oh and I’m also glad that Skype on iPhone will be free and official!