Reputation: 4343
I was hoping someone could help me .... I want to change the way that wordpress nav_menus outputs the menu listing.
Currently it outputs the following for example:
<div class="menu-main-menu-container">
<ul id="menu-main-menu" class="menu">
<li id="menu-item-48" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-5 current_page_item menu-item-48"><a href="#">Home</a></li>
<li id="menu-item-49" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-49"><a href="#">About</a></li>
</ul>
</div>
I would like it to output as follows:
<ul class="cssMenu">
<li class="lvl01"><a href="/" class="">Home</a></li>
<li class="lvl01"><a href="/about/" class="">About</a></li>
<li class="lvl01"><a href="#" class=""><span>Case Studies</span></a>
<ul class="">
<li class="lvl02"><a href="#" class="">Page Title One</a></li>
<li class="lvl02"><a href="#" class="">Page Title Two</a></li>
<li class="lvl02"><a href="#" class="">Page Title Three</a></li>
<li class="lvl02"><a href="#" class="">Page Title Four</a></li>
</ul>
</li>
<li class="lvl01"><a href="/category/news/" class="">News</a></li>
</ul>
If anyone has any clue on how to go about this, i would greatly appreciate some help
Cheers,
Upvotes: 0
Views: 2393
Reputation: 119
Try to use this Wordpress filter...
http://codex.wordpress.org/Plugin_API/Filter_Reference/nav_menu_css_class
Upvotes: 0
Reputation: 1483
I wrote a tutorial on this a little ago.. maybe you'll find it helpful:
www.1stwebdesigner.com/wordpress/wordpress-wp-nav-menu-tutorial/
Upvotes: 0
Reputation: 17561
You need to use a custom menu walker. See http://codex.wordpress.org/Function_Reference/wp_nav_menu and T5_Nav_Menu_Walker_Simple — Gist and http://www.mattvarone.com/wordpress/cleaner-output-for-wp_nav_menu/ and other Google results for "wordpress menu walker."
Upvotes: 0