我创建了一个新菜单,它显示完美,但问题出在选择上,它将我发送到不存在的页面或帖子,问题,我想,.....更改格式输出,我不知道我怎么能解决这个问题。
我的代码:
<?php
wp_create_nav_menu( 'Mobil Menu', array( 'slug' => 'theme_footer_mobil_menu' ) );
class Walker_Nav_Menu_Dropdown extends Walker_Nav_Menu
{
// don't output children opening tag (`<ul>`)
public function start_lvl(&$output, $depth){}
// don't output children closing tag
public function end_lvl(&$output, $depth){}
public function start_el(&$output, $item, $depth, $args){
// add spacing to the title based on the current depth
$item->title = str_repeat(" ", $depth * 4) . $item->title;
// call the prototype and replace the <li> tag
// from the generated markup...
parent::start_el(&$output, $item, $depth, $args);
$output = str_replace('<li', '<option', $output);
}
// replace closing </li> with the closing option tag
public function end_el(&$output, $item, $depth){
$output .= "</option>\n";
}
}
wp_nav_menu(array(
"menu"=>"Mobil Menu",
'theme_location' => 'primary',
'walker' => new Walker_Nav_Menu_Dropdown(),
'items_wrap' => '<select class="footer_menu_mobile" onChange="if(this.selectedIndex!=0) self.location=this.options[this.selectedIndex].value">%3$s</select>',
));
?>
显示完美的下拉菜单,但真正的问题是从选定的菜单启动 URL,此 URL 显示有空格且没有权限
感谢和问候 !