javascript - wp_register_script unable to link bootstrap JS

This is my function to load the bootstrap files. function load_js(){wp_register_script('bootstrap', get_templ

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 badge
Add a comment  | 

1 Answer 1

Reset to default 2
function 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744996995a4605254.html

相关推荐

  • javascript - wp_register_script unable to link bootstrap JS

    This is my function to load the bootstrap files. function load_js(){wp_register_script('bootstrap', get_templ

    1天前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信