[wp-hackers] Adding class to first menu item of submenu in wp_nav_menu
Gavin Pearce
Gavin.Pearce at 3seven9.com
Sun Jun 27 22:28:19 UTC 2010
Evening all,
Just wondering if any of you kind ladies and gentleman has found a way to add a "first" class, to the first item of each submenu within a menu generated by wp_nav_menu.
Adding a class to the first ever li is easy (preg_replace on menu-item x1), adding it to the first li "under" each and every submenu UL has confused me, without going into stupidly complex preg_replaces.
E.g. (look for the FIRST's) ::
<ul>
<li class="menu-item">Home</li>
<li class="menu-item">Page1
<ul class="submenu">
<li class="FIRST menu-item">Subpage 1</li>
<li class="menu-item">Subpage 2</li>
</ul>
</li>
<li class="menu-item">Page3</li>
<li class="menu-item">Page4
<ul class="submenu">
<li class="FIRST menu-item">Subpage 1</li>
<li class="menu-item">Subpage 2</li>
</ul>
</li>
</ul>
Gav
More information about the wp-hackers
mailing list