How to include JQuery on your WordPress theme

July 17, 2009 at 1:42 pm

JQuery is definitely a great Javascript framework, which allow you to, among other things, create stunning visual effects. Including JQuery is easy. But do you know that WordPress can make it even easier?

The first thing you have to know is that WordPress already have JQuery (It is used in the dashboard) so you don’t need to download a new copy of JQuery to your WordPress server.
Then, we just have to use the wp_enqueue_script() function, which automatically enqueue a Javascript file in your theme header.
Open your header.php file and paste the following within the <head> and </head> tags:

<?php wp_enqueue_script("jquery"); ?>

By the way, Cristian just wrote a very interesting post at Cats Who Code. It is all about WordPress Theme Frameworks so be sure to check it out!

Thanks to Chris Coyier for the tip!