admin管理员组文章数量:1410673
This is my function to load the bootstrap files.
function load_js()
{
wp_register_script('bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', 'jquery', false, true );
wp_enqueue_script('bootstrap');
}
add_action('wp_enqueue_scripts', 'load_js');
I would expect this to route to:
/wp-content/themes/themename/js/bootstrap.min.js
But instead it does:
/wp-content/themes/themenamejs/bootstrap.min.js
This is my function to load the bootstrap files.
function load_js()
{
wp_register_script('bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', 'jquery', false, true );
wp_enqueue_script('bootstrap');
}
add_action('wp_enqueue_scripts', 'load_js');
I would expect this to route to:
http://site.test/wp-content/themes/themename/js/bootstrap.min.js
But instead it does:
http://site.test/wp-content/themes/themenamejs/bootstrap.min.js
Share Improve this question edited Nov 17, 2019 at 14:20 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked Nov 17, 2019 at 9:01 FraserFraser 211 bronze badge1 Answer
Reset to default 2function load_js()
{
wp_register_script('bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), false, true );
wp_enqueue_script('bootstrap');
}
add_action('wp_enqueue_scripts', 'load_js');
Use with array('jquery')
instead of 'jquery'
Refference here. It says: use array.
本文标签: javascriptwpregisterscript unable to link bootstrap JS
版权声明:本文标题:javascript - wp_register_script unable to link bootstrap JS 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744996994a2636736.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论