You need to extend Walker_Nav_Menu
in such a way that it only outputs, if I understand you, items that are not “zero” depth– top level.
class my_extended_walker extends Walker_Nav_Menu {
function start_lvl(&$output, $depth, $args ) {
if (0 !== $depth) {
parent::start_lvl($output, $depth, $args);
}
}
function end_lvl(&$output, $depth, $args) {
if (0 !== $depth) {
parent::end_lvl($output, $depth, $args);
}
}
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
if (0 !== $depth) {
parent::start_el($output, $item, $depth, $args, $id);
}
}
function end_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
if (0 !== $depth) {
parent::end_el($output, $item, $depth, $args, $id);
}
}
}
// testing
wp_nav_menu(
array(
'walker'=>new my_extended_walker(),
'menu' => 'mymenu'
)
);
1
solved show only a given level in nav menu