While building a custom theme, I've been stuck on how to add a CSS class to a certain theme menu (meaning a custom menu that is associated with a theme menu position).
So far, in my template I have
<?php if (has_nav_menu('main-menu')) : ?>
<nav class="topmenu" role="navigation">
<?php
wp_nav_menu(array(
'menu-class' => 'topmenu--list',
'theme_location' => 'main-menu',
'fallback_cb' => false,
));
?>
</nav>
<?php endif; ?>
So, I'm sort of missing a 'menu-item-class'
option in the wp_nav_menu's $args
array. How can I pass a CSS class to each menu item?
Just to be clear, I do not want an editor to set a CSS class to each menu item manually in admin backend. I want to add the CSS class to each menu item programmatically.