Since a lot of people come to my blog looking for a way to add jQuery into their wordpress themes, it turns out that there is a better way to do it than the way that I previously blogged. You can include jQuery from the current WordPress install by calling:
wp_enqueue_script("jquery");
Followed by:
wp_head();
You can even use it to include the jQuery library that you are adding with your theme (so that it works after wordpress updates their library):
//First you have to get rid of the one that wordpress includes: wp_deregister_script('jquery'); //Then you have to replace it with your own: wp_register_script('jquery', (bloginfo("template_url")."/js/jquery.min-1.3.2.js"), false, '1.3.2'); //or you could use the one that google so kindly provides: wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"), false, '1.3.2'); //Then enqueue it wp_enqueue_script('jquery');
Related posts:
- JQuery and WordPress
- A couple useful jQuery Snippets
- Updated WordPress
- Using the jQuery-UI Autocomplete Widget
- Ajaxy Pagination using jQuery
Tags: AJAX, Computing, jQuery, PHP programming language, System software, Web application frameworks, WordPress, World Wide Web, wp_head