2013-04-23 84 views
0

我创建了一个新的菜单,它显示完美,但问题是与选择,它发送给我的页面或帖子不存在,问题,我想,.....更改格式输出我不知道我该如何解决这个问题。WordPress的创建菜单

我的代码:

<?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("&nbsp;", $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显示与空格,没有权利

Thank's问候 !

回答

0

为什么不使用简单的css drop-dwo菜单?

这里是一个工作示例:

.menu{ 
    border:none; 
    border:0px; 
    margin:0px; 
    padding:0px 0px 0px 20px; 
    font-family:"Arial"; 
    font-size:12px; 
    font-weight:bold; 
    list-style-type:none; 

    } 
.menu ul{ 
    height:35px; 
    list-style:none; 
    margin:0; 
    padding:0; 

    } 
.menu li{ 
    float:left; 
    padding:0px; 
    list-style-type:none; 

    } 
.menu li a{ 
    background-color:#CC0000; 
    color:#fff; 
    display:block; 
    font-weight:bold; 
    line-height:35px; 
    margin:0px; 
    padding:0px 13px; 
    text-align:center; 
    text-decoration:none; 
    list-style-type:none; 
    } 

    .menu li a:hover { 
background-color:#000; 
border-radius:3px; 
    color:#fff; 
    text-decoration:none; 
    list-style-type:none; 
    } 
.menu ul li:hover a{ 
background-color:#000; 
border-radius:-3px; 
    color:#fff; 
    text-decoration:none; 
    list-style-type:none; 
    } 
.menu li ul{ 
background-color:#ccc; 
color:#FFFFFF; 
    display:none; 
    height:auto; 
    padding:0px; 
    margin:0px; 
    border:0px; 
    position:absolute; 
    width:150px; 
    z-index:230; 
    /*top:1em;*/ 
    } 

.menu li ul li ul { 
    margin-left:150px; 
    margin-top:-35px;  
} 

.menu li:hover > ul{ 
    display:block; 

    } 
.menu li li { 
background:#000000; 
    display:block; 
    float:none; 
    margin:0px; 
    padding:0px; 
    width:150px; 
    } 
.menu li:hover li a{ 
    background:none; 

    } 
.menu li ul a{ 
    display:block; 
    height:35px; 
    font-size:12px; 
    font-style:normal; 
    margin:0px; 
    padding:0px 10px 0px 15px; 
    text-align:left; 
    } 

.menu li ul li:hover { 
    background:#CC0000; 
    border:0px; 
    color:#ffffff; 
    text-decoration:none; 
    } 
.menu p { 
    clear:left; 
    } 

这里是PHP

<?php $defaults = array(
    'theme_location' => 'Primary', 
    'menu'   => 'your menu name', 
    'container'  => 'ul', 
    'container_class' => 'menu-{menu slug}-container', 
    'container_id' => 'menu', 
    'menu_class'  => 'menu', 
    'menu_id'   => 'menu-{menuslug}[-{increment}]', 
    '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'   => '' 
); ?> 
       <?php wp_nav_menu($defaults); ?>