worpdress将标题中的jquery ui核心排入队列

时间:2017-07-26 20:26:43

标签: wordpress jquery-ui

我在谷歌上搜索了这个但是找不到满意的答案。我正试图在worpdess的头文件中加载jquery ui core,但似乎无法找到这样做的方法。在我的function.php文件中,我这样做:

function my_theme_scripts() {
wp_enqueue_script( 'jquery-ui-core');
}
add_action( 'wp_enqueue_scripts', 'my_theme_scripts' );

这会加载脚本但在页脚中。有谁知道这是否可能?或者我应该取消注册jquery ui并使用CDN吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

试试这个。

    add_action('wp_enqueue_scripts', 'my_theme_scripts');
    function my_theme_scripts(){
        if( is_admin() ) return;
        wp_deregister_script( 'jquery-ui-core' );
        wp_enqueue_script( 'jquery-ui-core', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js', array('jquery'), '1.12.1' );
    }