My theme has three 3 menus: two that are dropdown menus and one that is different. I want to remove the div, class, etc. from the menu that is different.
For Example:
I have three menus
- topnav ( drop down )
- mainmenu ( drop down)
- mymenu ( normal )
My current code:
<div id="megaMenu" class="megaMenuContainer megaMenu-nojs megaFullWidth megaMenuHorizontal megaMenuOnHover wpmega-autoAlign wpmega-withjs wpmega-noconflict"><ul id="megaUber" class="megaMenu"><li id="menu-item-987" class="menu-item menu-item-type-post_type menu-item-object-post current-menu-item ss-nav-menu-item-0 ss-nav-menu-item-depth-0 ss-nav-menu-reg"><a href="http://localhost/wordpress/?p=967"><span class="wpmega-link-title">who we are</span></a></li>
<li id="menu-item-986" class="menu-item menu-item-type-post_type menu-item-object-post ss-nav-menu-item-1 ss-nav-menu-item-depth-0 ss-nav-menu-reg"><a href="http://localhost/wordpress/?p=969"><span class="wpmega-link-title">management team</span></a></li>
<li id="menu-item-985" class="menu-item menu-item-type-post_type menu-item-object-post ss-nav-menu-item-2 ss-nav-menu-item-depth-0 ss-nav-menu-reg"><a href="http://localhost/wordpress/?p=971"><span class="wpmega-link-title">award</span></a></li>
<li id="menu-item-984" class="menu-item menu-item-type-post_type menu-item-object-post ss-nav-menu-item-3 ss-nav-menu-item-depth-0 ss-nav-menu-reg"><a href="http://localhost/wordpress/?p=973"><span class="wpmega-link-title">career</span></a></li>
<li id="menu-item-983" class="menu-item menu-item-type-post_type menu-item-object-post ss-nav-menu-item-4 ss-nav-menu-item-depth-0 ss-nav-menu-reg"><a href="http://localhost/wordpress/?p=975"><span class="wpmega-link-title">contact us</span></a></li>
</ul></div>
I want to remove everything from mymenu, just want to want <li>menu name </li>
. Additionally, I want active
class applied to activated menu item as <li class="active">menu name </li>
.
You can use another walker than WordPress pre-build one.
Add this to your functions.php file in the theme:
Then make sure to specify the new custom Walker when calling
wp_nav_menu()
.