Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 at 7:21
    
I know about that! this is for something different –  brodster Aug 3 at 7:24
    
is socialmedia your menu location slug? Please double check the menu location slug. –  Chinmoy Kumar Paul Aug 3 at 7:26
    
yes register_nav_menus( array( 'socialmedia' => __( 'Social Media Links', 'zevia' ), ) ); –  brodster Aug 3 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 at 9:15

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.