您好,我在这里有此脚本,需要将其放在当前的wordpress主题中,但对入队部分感到困惑。我知道我必须将hoverintent javascript保存在主题库中,我是否也将功能javascript保存在主题库中?抱歉,如果我没有弄清楚,请发表评论,如果这令人困惑!

jsfiddle.net/ctLevz8L/59/

最佳答案

从小提琴中获取JavaScript并将其保存到wp-content/themes/mytheme/js/hoverintent.js

然后,将以下内容添加到主题的functions.php文件中:

function enqueue_hoverintent {
    //Add the script and jquery-ui to the generated header.
    wp_enqueue_script(
        'my_hoverintent',
         get_stylesheet_directory_uri() . '/js/hoverintent.js',
         array('jquery-ui-core')
    );

    //Add the jqueryui css file from Google's CDN since it isn't included with WP
    wp_enqueue_style (
        'googlecdn_jqueryui_style',
         'https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css',
    );
}

add_action( 'wp_enqueue_scripts', 'enqueue_hoverintent' );

关于javascript - 需要帮助将一些JavaScript代码添加到我的wordpress主题中,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28312904/

10-12 00:10
查看更多