WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] WordPress wp_nav_menu skipping items OR not sorting items (7 posts)

  1. oskarmothander
    Member
    Posted 1 year ago #

    I have a menu like this (called "Meny"):

    Level1
    ...
    - Level2
    - ...
      - Level 3
      - Level 3 .. and so on.

    However doing this in sidebar-menu.php:

    $options = array(
            'container'      => '',
            'echo'           =>  false,
            'menu'           => 'Meny',
            'theme_location' => 'sidebar-menu',
        );
        $nav = wp_nav_menu($options);

    Outputs all level1 and level2 items but always only the first level3 child??? I've double checked and I do have several level3 items in "Meny".. :S

    If I remove 'menu' => 'Meny' it outputs all but then I loose the correct order!

  2. esmi
    Forum Moderator
    Posted 1 year ago #

    What theme are you using? Where did you download it from?

  3. oskarmothander
    Member
    Posted 1 year ago #

    I downloaded it from my brain... No it's a theme based on:
    http://wordpress.org/themes/responsive but me and my collegue has rewritten some of it, mostly front-end changes.

    I doubt it has anything to do with the theme. The page-menu is showing correctly in the site.

    header.php has this code:

    <?php wp_nav_menu(array(
        'depth'            => 2,
        'container'        => 'div',
        'theme_location'   => 'header-menu',
        'before'           => '<div class="a_wrap">',
        'after'            => '</div>',
        'menu'             => 'Meny',
        'items_wrap'       => '<ul id="%1$s" class="%2$s">
                                   <li id="menu_start" class="menu-item"> </li>%3$s
                                   <li id="menu_drift" class="menu-item">
                                        <div class="a_wrap">
                                            <a href="http://example.com">hardcoded tab</a>
                                        </div>
                                   </li>
                              </ul>',
        )
    );
    ?>
  4. esmi
    Forum Moderator
    Posted 1 year ago #

    What happens if you use the original Responsive theme? If you want 3 levels, why are you setting depth to 2?

  5. oskarmothander
    Member
    Posted 1 year ago #

    I want 2 levels (depths) in the main site-menu (header.php) but we also have a side-menu in (sidebar-menu.php) which we want to show 3 levels.

  6. esmi
    Forum Moderator
    Posted 1 year ago #

    So which one relates to the code above?

  7. oskarmothander
    Member
    Posted 1 year ago #

    Seems like the first menu is cached and used when wp_nav_menu is called the second time. It's weird it outputs the first level 3 childs though.

    I used wp_get_nav_menu_object() instead and that worked!

Topic Closed

This topic has been closed to new replies.

About this Topic