Just intercept the nav classes and search for the current-menu-item
class. This will give you the $item
it’s associated with.
add_filter( 'nav_menu_css_class', 'get_active_class', 10, 2 );
function get_active_class( $classes, $item )
{
if ( in_array( 'current-menu-item', $classes) ) {
// We found the active class!: $item
}
return $classes;
}
Now just grab your nav menu and apply the needed css classes or style="display:none"
to the others.