我需要根据用户在页面选项上选择的内容显示菜单。
我将用户的菜单名转换为变量,现在需要它通过wp\\u nav\\u menu进行解析。
我试着这样做,但不起作用:
$var = the_field(\'menu2\');
$params = array(
\'theme_location\' => \'\',
\'menu\' => $var, // <== This is what i want to do
\'container\' => \'div\',
\'container_class\' => \'\',
\'container_id\' => \'\',
\'menu_class\' => \'menu\',
\'menu_id\' => \'\',
\'echo\' => true,
\'fallback_cb\' => \'wp_page_menu\',
\'before\' => \'\',
\'after\' => \'\',
\'link_before\' => \'\',
\'link_after\' => \'\',
\'items_wrap\' => \'<ul id="%1$s" class="%2$s">%3$s</ul>\',
\'depth\' => 0,
\'walker\' => \'\'
);
wp_nav_menu( $params );
我也试过了
\'menu\' => \'$var\'
如果有人能帮助我,我将不胜感激
谢谢