• Resolved reddo

    (@reddo)


    Here is my code in the header

    <nav class="col-md-9" role="navigation">
      <?php wp_nav_menu(
        array(
          'theme_location'  => 'navigation',
          'menu'            => '',
          'container'       => false,
          'container_class' => 'menu-{menu slug}-container',
          'container_id'    => '',
          'menu_class'      => 'nav nav-pills',
          'menu_id'         => 'menu-{menu slug}',
          'echo'            => true,
          'fallback_cb'     => 'wp_page_menu',
          'before'          => '',
          'after'           => '',
          'link_before'     => '',
          'link_after'      => '',
          'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s</ul>',
          'depth'           => 0,
          'walker'          => ''
        )
      );
    ?>
    </nav>

    and this renders me

    <nav class="col-md-9" role="navigation">
      <div class="nav nav-pills">
        <ul>
          <li class="page_item page-item-1791 current_page_item"><a href="https://retesz.w.pw/biografia/">Biográfia</a></li>
          <li class="page_item page-item-1783"><a href="https://retesz.w.pw/">F?oldal</a></li>
        </ul>
      </div>
    </nav>

    From what I read in the codex:

    $menu_class
    (string) (optional) The class that is applied to the ul element which encloses the menu items. Multiple classes can be separated with spaces. Formerly known as $wrap_class.
    Default: menu

    It’s supposed to apply the class nav nav-pills to the ul, not the container div, especially because I turned off the container with 'container' => false.

    Can someone explain what I’m doing wrong.

    Any help is appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • This

    <li class="page_item">

    indicates that there is no menu assigned yet, so it’s using wp_page_menu() fallback. Try assigning some menu items and menu location.

    Thread Starter reddo

    (@reddo)

    How could I have missed that? O.o

    I made the menu and saved it, I just forgot to assign it to the location.

    Thanks for your time!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_nav_menu not rendering menu_class correctly’ is closed to new replies.