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

John O'Nolan john.wp at onolan.org
Fri May 14 00:48:07 UTC 2010


As Nacin said, you can add custom classes to any menu item within the  
new menus screen.

Under the Screen Options tab, enable the check box for custom CSS and  
hey presto. Add a custom class to the first, second, last, which ever  
menu item you like.




On 14 May 2010, at 01:40, Nathan Rice wrote:

> Use jQuery, then.
>
> ------------------
> Nathan Rice
> WordPress and Web Development
> www.nathanrice.net | twitter.com/nathanrice
>
>
> On Thu, May 13, 2010 at 6:36 PM, Jason Bobich <jason_bobich at hotmail.com 
> >wrote:
>
>>
>> In using "li:first-child", I guess the argument of supporting ie6  
>> wouldn't
>> pass for a good counter argument! However it still would be nice if  
>> there
>> was title_li (or similar) parameter for the wp_nav_menu() function.
>>
>>> From: wp at andrewnacin.com
>>> Date: Thu, 13 May 2010 18:29:10 -0400
>>> To: wp-testers at lists.automattic.com
>>> Subject: Re: [wp-testers] adding class to first menu item when using
>> wp_nav_menu()?
>>>
>>> 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.
>>>>
>>> _______________________________________________
>>> wp-testers mailing list
>>> wp-testers at lists.automattic.com
>>> http://lists.automattic.com/mailman/listinfo/wp-testers
>>
>> _______________________________________________
>> wp-testers mailing list
>> wp-testers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-testers
>>
> _______________________________________________
> wp-testers mailing list
> wp-testers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-testers



More information about the wp-testers mailing list