0
votes

I am using the WordPress menu widget to generate menu items as follows (using the Bootstrap framework):

<nav class="navbar navbar-toggleable-md">
<div class="container">
    <div class="collapse navbar-collapse" id="navbarNav">
        <?php wp_nav_menu(array('theme_location' => 'header-menu','menu_class' => 'navbar-nav','container' => 'false'));?>
    </div>
</div>
</nav>

I have these functions to add some addtional style:

function add_link_atts($atts) {
    $atts['class'] = "nav-link";
    return $atts;
}

add_filter( 'nav_menu_link_attributes', 'add_link_atts');

Question is ... I would like a div with class col-md-3 to wrap each of my four menu items so they can be laid out into bootstrap columns.

Where would I add the code in wp_nav_menu that should append before and after each menu item?

ie. how to add the <div class="col-md-3"> element before each WordPress menu item, and </div> element after each menu item.

1
This answer is here you can read and add class in menu li.WPMK Organization
This answer is here you can read and add class in menu li.WPMK Organization

1 Answers

0
votes

I would like a div with class col-md-3 to wrap each of my four menu items so they can be laid out into bootstrap columns.

  1. The Bootstrap navbar is NOT designed and will NOT work with any column classes.

  2. You don't need any column classes for controlling the layout of the navbar elements.