WordPress.org

Forums

[resolved] wp_nav_menu 'container' not working (3 posts)

  1. stefandunn
    Member
    Posted 1 year ago #

    I have the following code to try and achieve a menu wrapped in a nav tag but it doesn't seem to work. My code is:

    wp_nav_menu(array(
       'container' => 'nav',
       'container_id' => 'navigation'
    ));

    The output is:

    <div class="menu">
         <ul>
              <li class="page_item page-item-2 current_page_item"><a href="http://localhost/Portfolio/">Homepage</a></li>
        </ul>
    </div>
  2. stefandunn
    Member
    Posted 1 year ago #

    I didn't add theme support for menus, that was causing the issue. Obviously it was then acknowledging the fallback function.

  3. sanjeevani
    Member
    Posted 8 months ago #

    <?php
    wp_nav_menu( array(
    'menu' => '',
    'container' => 'div',
    'container_class' => '',
    'container_id' => '',
    'menu_class' => 'menu',
    'menu_id' => '',
    'echo' => true,
    'fallback_cb' => 'wp_page_menu',
    'before' => '',
    'after' => '',
    'link_before' => '',
    'link_after' => '',
    'depth' => 0,
    'walker' => '',
    'theme_location' => ''
    ) );
    ?>

    try using this.

Topic Closed

This topic has been closed to new replies.

About this Topic