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 Creating Bootstrap Navigation in WordPress

Nav Menu not formating Bootstrap 4 WP 4.8.1

My nav is showing up as default Blue links all run together like 1 long word with no padding. Do I need to adjust my settings in the $args array or do I need to change the class or id tags in the bootstrap div? I'm lost please help.

I am using the latest version of Jumbotron with Bootstrap 4.0.0 beta

Here is my header.php code

<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../../../favicon.ico">

    <title>Jumbotron Template for Bootstrap</title>

    <?php wp_head(); ?>


  <body <?php body_class(); ?>>

    <nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
      <a class="navbar-brand" href="<?php bloginfo( 'url' ); ?>"><?php bloginfo( 'name' ); ?></a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>

      <div class="collapse navbar-collapse" id="navbarsExampleDefault">
          $args = array(

            'menu'          => 'header-menu',

            'menu_class'    => 'nav navbar-nav',

            'container'     => 'false'

          wp_nav_menu( $args );

and here is my functions.php code


function theme_styles() {

    wp_enqueue_style( 'bootstrap_css', get_template_directory_uri() . '/css/bootstrap.min.css' );
    wp_enqueue_style( 'main_css', get_template_directory_uri() . '/style.css' );
add_action( 'wp_enqueue_scripts', 'theme_styles' );

function theme_js() {

    wp_enqueue_script( 'bootstrap_js', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '', true );

add_action( 'wp_enqueue_scripts', 'theme_js' );

//add_filter( 'show_admin_bar', '__return_false' );

add_theme_support( 'menus' );

function register_theme_menus() {
            'header-menu' => __( 'Header Menu' )
add_action( 'init', 'register_theme_menus' );


1 Answer

Jon Speake
Jon Speake
3,466 Points

I was also struggling with this, and after hours of research and trying so many different things i eventually got it working following this tutorial https://napitwptech.com/tutorial/wordpress-development/integrate-bootstrap-navbar-4-wordpress-theme/