Using wp_nav_menu function to set classes
-
I am trying to use the wp_nav_menu() function to set classes on a menu, and I thought I was following the documentation exactly, but I’m not getting what I expected. Here is the code:
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'container' => 'nav', 'container_class' => "collapse navbar-collapse", 'menu_class' => "navbar-nav", 'menu_item' => 'nav-item', ) ); ?>
I expected a
nav
with the classes in container_class that contained aul
with the classes in menu_class.But what I get is a
<nav class="navbar-nav">
, inside it is a ul with no classes.
Nothing has the classescollapse navbar-collapse
.Is anyone able to explain why it is overwriting like this, or what I have wrong here?
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Using wp_nav_menu function to set classes’ is closed to new replies.