WordPress: wp_nav_menu – add class on UL?
The element, which in our case ‘ul’ tag, and than we can specify the class and then we can assign in the ‘menu_class’. And then the sample code is below:
wp_nav_menu( array( 'theme_location' => 'top-menu', 'container' => 'ul', 'menu_class'=> '[add-your-class-here]' ) );
We have to add the class to the ul of wp_nav_menu. Use the code:
<?php $defaults = array( 'menu_class' => 'menu', 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>', ); wp_nav_menu( $defaults ); ?>
As per the wordpress codex as were are changing the menu from ‘menu_class’ => ‘menu’, and also we can change the class of the ul , instead we can make the changes of the class of the div wrapping with the ul.