You can do this with the nav_menu_link_attributes
filter.
add_filter( 'nav_menu_link_attributes', 'wpse156165_menu_add_class', 10, 3 );
function wpse156165_menu_add_class( $atts, $item, $args ) {
$class="class"; // or something based on $item
$atts['class'] = $class;
return $atts;
}
Related Posts:
- Displaying wp menus by name without using theme locations
- Setting a Default ‘Theme Location’ When Creating a Menu
- My Admin bar covers my sticky navbar [closed]
- How to make navigation a list without a plugin? [duplicate]
- wp_nav_menu(), how to change class?
- get_template_part vs action hooks in themes
- Display a different theme for not logged-in users
- What can I hook into after_setup_theme?
- How to add menu support to a theme?
- How do I “unhook” / de-register jQuery so that it’s not called as part of wp_footer();?
- Select menu on browser resize
- Extend walker – navigation, adding data attribute to a tag
- How to highlight the current page in the nav menu?
- how to change WordPress menu markup/classes
- Custom Nav Walker Displaying Values in Sub Menu
- Where is definied the theme location for the main menu in a WordPress template?
- How to add theme support?
- WordPress is adding margins and padding to my custom menu?
- Menu item added in wp_nav_menu_items filter is never highlighted
- How to make theme elements customizable in wordpress?
- Single-level menu option? Another way?
- Primary navigation menu & footer not showing in category / tag page
- Using a page as home, how do I prevent nav from setting both home and page links active?
- Theme Development: Starter Content after hook
- Where am I doing wrong in my theme menu?
- Admin: sub menu doesnt display under apperance when activate my themes
- 3 Level Deep Navigation Menu Not Showing All Levels
- How to add menù section to my WordPress template?
- Thesis -style Navigation
- how do i develop a global nav and local nav to be wordpress dynamic?
- Why is my container argument not working for wp_nav_menu() [closed]
- Some doubts about WordPress handle the horizontal main menu visualization
- Custom nav menu not showing
- how to create/register menu items that can be added to menus later
- Why nav_menu_css_class doesn’t work with apply_filters?
- Programatically Created Menu not Editable in Dashboard
- 3 Level Menu Navigation (3rd Level not displaying)
- Theme: dropdown hover menu not showing up in IE/Edge
- How can I show a custom WordPress menu anywhere I want on my website?
- Show all menu levels except top level. How to exclude top level of a menu?
- WordPress Menu item > Sub menu Class update
- Menu names not getting translated
- Need help with adding custom wordpress menu and sub-menu
- How to achieve this navigation style in wordpress navigation
- Fallback dosen’t work when not using ‘menu’ attribute
- Primary Menu Showing All Pages With No Sub-Nav
- How to add drop symbol to parent nav items which have child
- WordPress 3.9 two menus in same position?
- What’s the policy for building a theme that doesn’t support widgets/menus?
- How to automatically set a Template Page Name next to a page in menu screen such as WooCommerce pages, front page, or posts page in wordpress?
- Dynamic nav menu with icons [closed]
- wp_nav_menu_items callback not triggered
- Why is wp_nav_menu() not removing the container around the nav ?
- Theme automatically inserting “more” tag on every post
- How get the 10 most viewed pages (not post)
- How can I change the title of the Home link in the navigation bar?
- How do I move menu to the bottom in Custom Community theme?
- adding navigation to genesis themes
- Header links also appearing in the footer
- How to close open divs in post loop
- Display Today’s date outside the loop?
- Standard Way To Do Custom Work Within A Page?
- Using wp_enqueue_script with social media buttons?
- Create and style menu
- Confused on loading page content
- Displaying Tags for the Page I’m On?
- Custom link color or stylesheets
- How to convert that page to a wordpress template? [closed]
- Toolbox theme using printif statement – help needed understanding code block
- Show post thumbnail only if it exists using timthumb
- Add Dynamic Sidebar to Exisiting WordPress Theme [closed]
- Creating Multiple Menus in the Thesis Theme?
- php file child theme directory not overriding parent theme php file [duplicate]
- Any Cool WordPress Theme Editor? [closed]
- How to Create a Multi Purpose Theme?
- Showcase your wordpress themes [closed]
- How can I install my custom-made theme on a wordpress.com blog? [closed]
- Turning WordPress Into full-featured website?
- How to add or remove borders in navigation menu?
- How do I middle-align my header menu items in WordPress [closed]
- Getting all months in one year WordPress Archive
- How to highlight current menu bar base on the URL?
- can’t add EVENT LISTENER to a element
- Global Navigation menu in diiferrent wordpress setups
- What is The Best Way to Make Parallax header effect for wordpress theme ?? pure CSS or using JavaScript? [closed]
- Why am I getting posts back when I shouldnt
- Purchased Theme to Custom Made Theme? [closed]
- How to make website with many template that active [closed]
- Custom Single Page Portfolio Theme [closed]
- Image Size wrong during upload
- Fatal error: Call to undefined function the_posts_navigation()
- How to remove proudly created by WordPress in theme?
- getting id of page
- Roll my own theme or customize an existing one [closed]
- How to create full header but keep content narrow
- Why do some sites show themes/”themename” as the only theme?
- Is there any open source WordPress Themes?
- How do I add new layout width options in WordPress editor?
- Correct way to make a custom block theme responsive
- .submenu class missing in output from wp_nav_menu