2

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

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.

  • Thanks, but that didn't seem to change anything. When I look at the source the bootstrap css is still linked like: <script type='text/javascript' src='test.test/wp-content/themes/themenamejs/…> – Fraser Nov 17 at 10:49
  • It looks like true. Maybe you added any filter function? – bilimokur Nov 17 at 10:58
  • Haven't added a filter function. I am loading the bootstrap css in a similar way and having no issues: wp_register_style('bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css', array(), false, 'all' ); wp_enqueue_style('bootstrap'); – Fraser Nov 17 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.