how to install bootstrap to twentyfourteen theme

Im new with using wordpress and im wondering if it is possible to install bootstrap to my twentyfourteen theme? Thanks!

1 Answer
1

The best way to include bootstrap in your theme is to enqueue bootstrap CSS and JS in your functions.php file.

This is how you can enqueue bootstrap CSS and JS from CDN hosted version.

function my_scripts_enqueue() {
    wp_register_script( 'bootstrap-js', '//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js', array('jquery'), NULL, true );
    wp_register_style( 'bootstrap-css', '//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css', false, NULL, 'all' );

    wp_enqueue_script( 'bootstrap-js' );
    wp_enqueue_style( 'bootstrap-css' );
}
add_action( 'wp_enqueue_scripts', 'my_scripts_enqueue' );

If you do not want to use CDN hosted version then download and put the bootstrap stuff in your theme, and include it like this.

function my_scripts_enqueue() {
    wp_register_script( 'bootstrap-js', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), NULL, true );
    wp_register_style( 'bootstrap-css', get_template_directory_uri() . '/css/bootstrap.min.css', false, NULL, 'all' );

    wp_enqueue_script( 'bootstrap-js' );
    wp_enqueue_style( 'bootstrap-css' );
}
add_action( 'wp_enqueue_scripts', 'my_scripts_enqueue' );

Leave a Comment