editting wp_nav_menu() so it prints DIVs instead of LIs

我们两清 提交于 2019-12-11 01:53:33

问题


I have a header navigation with kinda difficult hover effect. In order to make it dynamic and NOT hard-coded, I'm gonna have to use spans inside list elements or even better I'm gonna need entire navigation done using DIVs.

Is there a way to edit the wordpress function wp_nav_menu() (codex definition) so that it will give me divs that I want instead of ul-li hierarchy?

Another solution is to build it the common way but then append spans to it using jQuery. But that's my last resort.

Has anyone had similar experiences?

Thank you

Edit:

instead of

<ul>
  <li>...</li>
  <li>...</li>
</ul>

I'm gonna need:

<div class="x">
 <div class="y">
   <div class="z">
   </div>
 </div>
 <div class="y">
   <div class="z">
   </div>
 </div>
 <div class="y">
   <div class="z">
   </div>
 </div>
</div>

回答1:


You need to use a custom menu walker. See http://codex.wordpress.org/Function_Reference/wp_nav_menu and http://www.mattvarone.com/wordpress/cleaner-output-for-wp_nav_menu/ and other Google results for "wordpress menu walker"



来源:https://stackoverflow.com/questions/9003918/editting-wp-nav-menu-so-it-prints-divs-instead-of-lis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!