开发者

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

开发者 https://www.devze.com 2023-03-15 04:59 出处:网络
I\'m creating a WordPress widget plugin. jQuery is not loading in my WordPress theme page. function my_init_method() {

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

精彩评论

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