I'm creating a WordPress widget plugin. jQuery is not loading in my WordPress theme page.
function my_init_method() {
#if (!is_admin()) {
wp_deregister_script( 'j开发者_高级运维query' );
wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js');
wp_enqueue_script( 'jquery' );
#}
}
add_action('wp_head', array($this, 'load_script'));
You may want to replace 'wp_head' with 'init' or other actions. According to http://codex.wordpress.org/Function_Reference/wp_enqueue_script,
Note that you have to enqueue your script before wp_head is run, even if it will be placed in the footer.
精彩评论