[wp-testers] adding class to first menu item when using wp_nav_menu()?

Andrew Nacin wp at andrewnacin.com
Thu May 13 22:29:10 UTC 2010


li:first-child?

You can otherwise use an existing items filter I imagine, or add the class
manually to the menu item. I see no reason to offer something that can
otherwise be achieved in CSS however.

On Thu, May 13, 2010 at 6:26 PM, Jason Bobich <jason_bobich at hotmail.com>wrote:

>
> Is it possible to add a class to the first menu item when showing a menu
> with wp_nav_menu()?
>
> Or is there a way to completely remove the wrapping ul tag so my theme's
> markup could be something like this:
>
> <ul>
>    <li class="first"><a href="" title="">HOME</a></li>
>    <?php wp_nav_menu(); ?>
> </ul>
>
> Similar to how if you were using wp_list_pages you could do:
>
> <ul>
>
>    <li class="first"><a href="" title="">HOME</a></li>
>
>    <?php wp_list_pages('title_li='); ?>
>
> </ul>
>
> My main goal is trying to figure out a way to add special styling to the
> first menu item, and I'm not sure if there's a way to go about doing this?
> Any tips on this?
>
> Would be a cool feature if it's not already implemented to add a class to
> the first menu item.
>


More information about the wp-testers mailing list