开发者

In WordPress widget, how to load jQuery into the theme page?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜