Using jQuery in your WordPress Theme or Plugin

10 October 2011

Having used jQuery and WordPress together on a number of plugins and themes, I thought I'd share some tips that I have learned. The following are 5 clear, concise, and relevant tips that you should know when using jQuery in your WordPress Theme or Plugin.

 

1. Use wp_enqueue_script()

 

The traditional way to include jQuery in an HTML page is with the script tag. When working with WordPress, you should *never* do this. To avoid conflicts and other potential problems, you'll want to load jQuery using the following code:


function my_init() {
	if (!is_admin()) {
		wp_enqueue_script('jquery');
	}
}
add_action('init', 'my_init');

Sumber : Jasa Pembuatan Website, Siakad, Simpeg dan SIM Rumah Sakit https://klatenweb.com
Selengkapnya : https://klatenweb.com/artikel/672/Using-jQuery-in-your-WordPress-Theme-or-Plugin.html