Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress From Bootstrap to WordPress Setup a Bootstrap Theme Add Bootstrap JS via the functions.php File

Bootstrap not loading

I tried following the author but my bootstrap isn't being loaded. it seem i am doing same excatly as author and my files are correctly placed under respective folder. Following is my code

function theme_js(){
          global $wp_scripts;
          wp_register_script( 'html5_shiv', 'https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js', '', '', false );
          wp_register_script( 'respond_js', 'https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js', '', '', false );

          $wp_scripts->add_data( 'html5_shiv', 'conditional', 'lt IE 9' );
          $wp_scripts->add_data( 'respond_js', 'conditional', 'lt IE 9' );
          wp_enqueue_script( 'bootstrap_js', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '', true );

};

add_action('wp_enqueue_scripts','theme_js');
Lucas Santos
Lucas Santos
19,315 Points

I don't see anything wrong in this code here unless it is something else. But I would remove that semicolon after the last curly brace ending the function. That's not needed.

and I also see a period after the semicolon in the add_action at the bottom. I don't know if that was by accident or not but if not remove it, that is wrong

Lucas Santos That was a typo, i fixed it. But still not able to work. Is there anything mandatory that needs to be included for it to work?

Lucas Santos
Lucas Santos
19,315 Points

What Ludvík said, you need the wp_head();function in the header.php and the wp_footer(); in the footer.php

1 Answer

Ludvík Matějíček
Ludvík Matějíček
12,557 Points

in header.php file you need add before end head tag wp_head function and in footer.php wp_footer function

Ludvík Matějíček After 2 days of trying everything, i finally got the problem. i was missing wp_footer();