How to add Bootstrap to WordPress

Do you want to use the popular Boostrap framework in your WordPress website? It is actually very simple to do and we got you covered. The first thing you will be asking yourself is how to load the Bootstrap css file into the WordPress core. This can be easily done with 1 line of code. We will give you an example for if you are hosting the file yourself or if you want to use a CDN.

How to add Bootstrap to WordPress

  1. Download or copy the CDN path of the latest Bootstrap version from https://getbootstrap.com/
  2. Open the functions.php file in your theme directory (wp-content/themes/theme-folder/functions.php)
  3. Add the following line to the bottom of the file

If you want to use the Bootstrap CDN:


wp_enqueue_style('bootstrap-css', 'https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css');

Replace the URL with the latest Bootstrap version if there is a newer version available.

If you want to use a self hosted Bootstrap file you need to upload the latest Bootstrap version to your theme directory and use the following code.


wp_enqueue_style('bootstrap-css', get_stylesheet_directory_uri() . '/bootstrap.min.css' );