Don’t know if this is the best way but i would go like this-
1) Hook into wp_nav_menu_objects
filter. The function will recieve a list of all menu-items. These menu items will already have the information regarding current page or current page’s ancestor(do a var_dump
once)
2) From these menu items, unset all the menu items which are not supposed to be shown & return the rest
foreach(<loop all items>) {
if(<this item's parent is current page or it's ancestor>)
// this element should be displayed
else
// this element should be deleted, unset() it
}
3) Override the walk
and/or display_element
methods in the custom walker, by default the children are added inside the parent’s <li>
tag, but as-per my understanding of your HTML you’ll need them seperate
Alternatively if you’re already overriding the walk
method but keeping most of it’s code in the custom walker, you can create a custom filter for the 2nd step above. This would make that loop much easier since the items will be already sorted