dongzhuo1880 2013-06-20 04:36
浏览 92

在Wordpress header.php中包含JQuery和JQuery UI

Ive tried a lot of versions of doing this I have found on SO and the net but none have worked for me.

I am running version 3.4.2. Perhaps there is a different way of doing it for this version?

My code is:

<?php
function my_scripts_method() {
  wp_enqueue_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js' );
  wp_enqueue_script( 'jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.8/jquery-ui.min.js' );

}

add_action( 'wp_enqueue_scripts', 'my_scripts_method' );
?>

I have this just above the </head> tag.

Can anyone help me out and tell me where I am going wrong?

  • 写回答

1条回答 默认 最新

  • doudang1052 2013-06-20 04:57
    关注

    Had similiar issue and I fixed it first deregister, register it to your value and than enqueue

    At http://codex.wordpress.org/Function_Reference/wp_register_script

    If you try to register or enqueue an already registered handle with different parameters, the new parameters will be ignored. Instead, use wp_deregister_script() and register the script again with the new parameters.

    wp_deregister_script('jquery');
    wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js');
    wp_enqueue_script('jquery');
    
    wp_deregister_script('jquery');
    wp_register_script('jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.8/jquery-ui.min.js');
    wp_enqueue_script('jquery');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!