简体   繁体   English

摆脱Wordpress导航菜单div

[英]Get rid of Wordpress navigation menu div

I am trying to create a navigation menu for a custom Wordpress theme using the wp_nav_menu() function. 我正在尝试使用wp_nav_menu()函数为自定义Wordpress主题创建导航菜单。 However, an when I use the function and reload the webpage, an annoying <div> html element appears and uses the class I want to style my <ul> with. 但是,当我使用该函数并重新加载网页时,会出现恼人的<div> html元素,并使用我想要为我的<ul>设置样式的类。 Has anyone came across this issue before and how can I fix this? 有没有人之前遇到过这个问题,我该如何解决这个问题?

The structure at the moment is like this: <div class="nav"> <ul> <li>Menu Item</li> </ul> </div> 目前的结构如下: <div class="nav"> <ul> <li>Menu Item</li> </ul> </div>

I would like it to look like this: <ul class="nav"> <li>Menu Item</li> </ul> Many thanks 我希望它看起来像这样: <ul class="nav"> <li>Menu Item</li> </ul>非常感谢

According to the docs for wp_nav_menu you can use wp_nav_menu(array('container' => false)) to disable the container. 根据wp_nav_menu的文档,您可以使用wp_nav_menu(array('container' => false))来禁用容器。

Edit: You have also have to set the theme_location option so the fallback doesn't get triggered. 编辑:您还必须设置theme_location选项,以便不会触发回退。

如果要删除容器div,则需要提及主题位置。

  wp_nav_menu( array( 'theme_location' => 'secondary-menu','container' => 'none','menu'=>'Secondary') ); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM