editting wp_nav_menu() so it prints DIVs instead o

2019-07-20 05:04发布

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条回答
We Are One
2楼-- · 2019-07-20 05:39

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"

查看更多
登录 后发表回答