Show specific menu item from wp_nav_menu based on id

If I understand what you want correctly, you can do this with CSS. You’ll call wp_nav_menu normally and let it generate all of the links, but then you’ll hide all of them except for the submenu of the current page.

You’re CSS would look something like this,

#sidebar ul.menu li
{
    display: none;
}

    #sidebar ul.menu li.current-page-parent,
    #sidebar ul.menu li.current-page-parent ul,
    #sidebar ul.menu li.current-page-parent ul.li
    {
        display: block;
    }

Update: You can check out http://thataboycreative.com to see an example of where I’ve used this before. Here’s the relevant CSS from that example:

ul.sub-menu
{
    display: none;
}

    #menu-main-navigation > li.current-menu-item ul.sub-menu,
    #menu-main-navigation > li.current-menu-ancestor ul.sub-menu
    {
        display: block;
    }

Leave a Comment