Child theme:Loading js files

The reason why your code isn’t working is because bloginfo() echoes the data where get_bloginfo() doesn’t. So dirname() isn’t really used. Using stylesheet_directory is better though since that won’t need the dirname() call at all.

You could also use the wrapper get_stylesheet_directory_uri() which adheres to the filter stylesheet_directory_uri.

This is your code corrected:

<script type="text/javascript" src="<?php bloginfo("stylesheet_directory'); ?>/bootstrap/js/bootstrap.js"></script>


However, the “WordPress-way” of adding scripts is by adding it the script queue. Doing it this way will ensure that your script is always loaded after it’s dependencies and it will also make it possible for other scripts to use your script as a dependency.

To add a script to WordPress’s queue you use wp_enqueue_script(). See the examples. Below is a script which should work for you. Add it to your theme’s functions.php file.

function enqueue_bootstrap() {
  wp_enqueue_script('twitter-bootstrap', get_stylesheet_directory_uri() . '/bootstrap/js/bootstrap.js', array('jquery'));
add_action('wp_enqueue_scripts', 'enqueue_bootstrap');