以下是解决方案。SergeyBiryukov的道具
更改需要将echo设置为false并在return$main\\u菜单中添加。
function tumble_menu( $args = array() ) {
/* Default arguments */
$defaults = array(
\'container\' => \'ul\',
\'menu_class\' => \'nav\',
\'menu_id\' => \'main_menu\',
\'theme_location\' => \'main-menu\',
\'echo\' => false,
\'before\' => \'\',
\'after\' => \'\',
\'link_before\' => \'\',
\'link_after\' => \'\',
\'depth\' => 1,
\'sort_column\' => \'menu_order\',
\'show_container\' => false,
\'walker\' => \'\',
);
$defaults = apply_filters( \'tumble_nav_default_args\', $defaults);
$args = wp_parse_args( $args, $defaults );
$main_menu = wp_nav_menu( $args );
return $main_menu;
}
function tumble_add_menu_wrapper($nav_menu, $begin, $end) {
// wrap our original HTML with the new tags
return $begin . $nav_menu . $end;
}
add_filter( \'tumble_menu_wrap\', \'tumble_add_menu_wrapper\', 10, 3 );
function tumble_do_menu_wrapper() {
$html = tumble_menu();
echo apply_filters( \'tumble_menu_wrap\', $html, \'div class="menu-button">Menu/div>\',\'\' );
}