首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Wordpress的Modernizr

Wordpress的Modernizr
EN

Stack Overflow用户
提问于 2017-03-10 10:57:46
回答 1查看 655关注 0票数 0

我在为wordpress添加modernizr时遇到了麻烦。我使用了一个子主题,顺便说一句。有人能帮我吗?

代码语言:javascript
复制
function foundation_assets() {

    // Load JavaScripts
    wp_enqueue_script('add_jquery', 'http://code.jquery.com/jquery-latest.min.js');
    wp_enqueue_script('new_jquerypp', get_stylesheet_directory_uri() . '/js/jquerypp.custom.js');
    wp_enqueue_script('bookblock', get_stylesheet_directory_uri() . '/js/jquery.bookblock.js');
    //wp_enqueue_script('extra', get_stylesheet_directory_uri() . '/js/extra.js');
    wp_enqueue_script('include_modernizr', get_stylesheet_directory_uri().'/js/modernizr.custom.js');

    //Load Stylesheet
    wp_enqueue_style( 'bookblock-css', get_stylesheet_directory_uri() . '/css/bookblock.css' );
}

add_action( 'wp_enqueue_scripts', 'foundation_assets' );

以下是我将其入队的代码。它保存在functions.php中。

已编辑:代码已更改。

EN

回答 1

Stack Overflow用户

发布于 2017-03-10 11:14:20

1)被注释掉了

2)你遗漏了结束语。

wp_enqueue_script('include_modernizr', get_stylesheet_directory_uri().'/js/modernizr.custom.js');

还要查看函数定义,以确保您的脚本将以正确的顺序加载https://developer.wordpress.org/reference/functions/wp_enqueue_script/

例如,wp_enqueue_script('new_jquerypp', get_stylesheet_directory_uri() . '/js/jquerypp.custom.js', array('add_jquery'));将确保new_jquerypp在jQuery本身之后加载

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42709371

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档