Adding a class to the links in wp_nav_menu

I’m working on a new wordpress site and I’m building it with the Foundation framework. I’d like to add the class “main” to the links in the navigation that is built with wp_nav_menu. Eventually, I’ll probably want to add the class “has-flyout” to others. Any idea on how to do this? I’m assuming I need to extend Walker (or can I do this with ‘items_wrap’?), but that seems like overkill.

Currently, I have:

wp_nav_menu( array(
    'theme_location' => 'primary_navigation',
    'container' =>false,
    'menu_class' => '',
    'echo' => true,
    'before' => '',
    'after' => '',
    'link_before' => '',
    'link_after' => '',
    'depth' => 0,
    'items_wrap' => '<ul class="nav-bar">%3$s</ul>'
));

Related posts

Leave a Reply

1 comment

  1. You could use:

    wp_nav_menu( array(
    ...
    'menu_class' => 'main-menu',
    ...
    

    And in your CSS (if that is what you want) access it like so:

    ul.main-menu li { background: white; }
    

    To add your “flyout” list-items maybe you could look into superfish? That system automatically adds “sf-with-ul” classes to list-items containing dropdowns.