WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to add a css class in menu list with this code:

    function my_special_nav_class( $classes, $item ) {

    if ( has_nav_menu( 'socialmedia' ) ) {
        $classes[] = 'btn-social btn-outline fa';

    return $classes;
add_filter( 'nav_menu_css_class', 'my_special_nav_class', 10, 2 );

but this adds the css class to all the menus. Any idea how to add the class just to "socialmedia"?

share|improve this question
Go to Appearances-> Menus page. Click on "Screen Options" and enable the CSS class. Now expand the individuals nav item and add the CSS in CSS class field. That's it. – Chinmoy Kumar Paul Aug 3 '14 at 7:21
I know about that! this is for something different – brodster Aug 3 '14 at 7:24
is socialmedia your menu location slug? Please double check the menu location slug. – Chinmoy Kumar Paul Aug 3 '14 at 7:26
yes register_nav_menus( array( 'socialmedia' => __( 'Social Media Links', 'zevia' ), ) ); – brodster Aug 3 '14 at 7:29
Now I got the idea. You need to add a custom walker for social media menu only. – Chinmoy Kumar Paul Aug 3 '14 at 9:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.