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 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.

本文标签: javascriptwpregisterscript unable to link bootstrap JS