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]
- Theme Customizer : how to create multiple-level panel
- Any official way to create an admin theme?
- wp_enqueue_scripts not called on search page?
- How to use bloginfo( ‘template_directory’ ) in array
- Should I update my _s theme?
- Different Admin Theme – Based on Role?
- How do I highlight the menu for a child page?
- Custom Nav Walker to show siblings and children of current branch?
- How to correctly add JQuery in a WP theme?
- how to change a theme slug
- I want to get the home root path
- How to add code in the content area in a WordPress theme?
- Should I use function_exists() and/or add_action() in theme development?
- Translation Issue with WordPress Theme Check in comment_form function
- Using esc_url with a hard coded url
- Broken template went invisible
- How to change database values on theme update
- WordPress theme switcher
- Problem with empty class attributes when running a filter on nav_menu_css_class
- Custom Nav Walker Trouble
- WP_bootstrap_Navwalker_issue [closed]
- Issue on Adding A Class to Bootstrap Navbar Walker Dropdown
- correct tags for validating input types
- Renaming a theme so it aids SEO and the theme used is hidden
- Dynamic menu links after header title
- WordPress 3.8 Backend Admin Color Scheme add more scheme how to do?
- Theme thumbnail in dashboard
- How to change the theme directory uri for localhost?
- featured content: which area does this cover [closed]
- Which cache is kicking
- Customizer: get_preview_url() inside customize_save_after hook
- How to modify mobile nav menu text in theme
- Is there a way to switch to another theme?
- New to WordPress – Read the Codex, Other Docs; Still Confused
- Why in this WordPress theme I can’t see the Main Menu?
- Does wordpress add their own classes into nav menus?
- Post archives link yields a 404 Not Found
- How to change a local wordpress installation xml export file urls? and change them to what if you don’t have a live website?
- Let user to upload multiple time
- register_theme_directory() sees custom themes directory, but blank frontend
- wp_nav_menu custom walker class
- How to create multiple pages in a client theme?
- Using Customizer value in an external PHP file inside a theme
- Theme customizer live preview JS- Trying to bind to an html image url without luck
- Purchased Theme to Custom Made Theme? [closed]
- How to make website with many template that active [closed]
- Image Size wrong during upload
- How to create full header but keep content narrow
- Prevent primary navigational menu from expanding during page load (WordPress / Astra Theme)