News

Using jQuery in your WordPress Theme or Plugin

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');
Versi cetak

Direkomendasikan


Jasa pembuatan aplikasi web berbasis PHP dan MySQL, Web Portal, Personal, Toko Online, Sistem Informasi Akademik, SIMPeg dan Rumah Sakit, Aplikasi Facebook, dan lain sebagainya termasuk penyedia domain dan hosting unlimited murah. Telp. dan WA 08175499076.