WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] wp_nav_menu 'container' not working

[Resolved] wp_nav_menu 'container' not working

  • stefandunn
    Member

    @stefandunn

    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>
Viewing 2 replies - 1 through 2 (of 2 total)
  • stefandunn
    Member

    @stefandunn

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

    sanjeevani
    Member

    @sanjeevani

    <?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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] wp_nav_menu 'container' not working’ is closed to new replies.