How to load Bootstrap in WordPress

Adding the following in child theme’s functions.php will load Boostrap‘s minified CSS and JS files in the header and footer respectively in your WordPress site.

add_action( 'wp_enqueue_scripts', 'custom_load_bootstrap' );
/**
 * Enqueue Bootstrap.
 */
function custom_load_bootstrap() {
    wp_enqueue_style( 'bootstrap-css', '//maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css' );

    wp_enqueue_script( 'bootstrap-js', '//maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js', array( 'jquery' ), CHILD_THEME_VERSION, true );
}

If CHILD_THEME_VERSION is not set in your child theme, it can be done like so:

define( 'CHILD_THEME_VERSION', '2.3.0' );

To get the URLs of the current latest versions of css and js files, go here.

This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.