您可以通过wp_nav_menu_args 滤器
假设你有一个这样的主题。。。
<?php
wp_nav_menu(array(
    \'theme_location\'   => \'second_level\',
    \'depth\'            => 2, // how many levels to show
    // prolly some other stuff here
));
 你可以加入
wp_nav_menu_args, 检查主题位置,将“深度”设置为1并删除子菜单。
<?php
add_filter(\'wp_nav_menu_args\', \'wpse87565_change_depth\');
function wpse87565_change_depth($args)
{
    if (!empty($args[\'theme_location\']) && \'second_level\' === $args[\'theme_location\']) {
        $args[\'depth\'] = 1;
    }
    return $args;
}