The below will add a class called class-here
to all menu items:
/**
* Filters the CSS class(es) applied to a menu item's list item element.
*
* @param array $classes The CSS classes that are applied to the menu item's `<li>` element.
* @param WP_Post $item The current menu item.
* @param stdClass $args An object of wp_nav_menu() arguments.
* @param int $depth Depth of menu item. Used for padding.
*
* @return Array $classes
*/
function theme_prefix_nav_menu_css_class( $classes, $item, $args, $dpeth ) {
$classes[] = 'class-here';
return $classes;
}
add_filter( 'nav_menu_css_class', 'theme_prefix_nav_menu_css_class', 10, 4 );
You could add this to your themes functions.php
file. There’s a bunch of other hooks when the WordPress WP Nav Walker creates the menus – Check out The Code Reference
Related Posts:
- wp_nav_menu(), how to change class?
- Add custom classes to anchor in wp_nav_menu
- How to add menu support to a theme?
- Extend walker – navigation, adding data attribute to a tag
- Displaying wp menus by name without using theme locations
- how to change WordPress menu markup/classes
- Setting a Default ‘Theme Location’ When Creating a Menu
- My Admin bar covers my sticky navbar [closed]
- WordPress is adding margins and padding to my custom menu?
- 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?
- how do i develop a global nav and local nav to be wordpress dynamic?
- Custom nav menu not showing
- Programatically Created Menu not Editable in Dashboard
- 3 Level Menu Navigation (3rd Level not displaying)
- 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?
- 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
- How to add drop symbol to parent nav items which have child
- WordPress 3.9 two menus in same position?
- How to make navigation a list without a plugin? [duplicate]
- Menu items description? Custom Walker for wp_nav_menu()
- How can I display a menu on certain pages only?
- Add Caret to Menu Items with Sub-Menus in WordPress Theme
- How to limit wordpress menu depth in admin panel
- wp_nav_menu sort order?
- How to determine if custom menu is active?
- Any walker causes blank menu?
- Return only top-level navigation items from a menu using wp_get_nav_menu_items
- Get last modified date for menu link
- Replace Home with image link inside custom header menu
- How to highlight the current page in the nav menu?
- How do I add a post to a menu
- Best practices: Custom theme sidebar menu – hardcode or widget?
- How do I highlight the menu for a child page?
- Custom Nav Walker Displaying Values in Sub Menu
- how to set more than one menus to the same theme location
- Custom Nav Walker to show siblings and children of current branch?
- CSS won’t style output of wp_nav_menu() correctly
- Where is definied the theme location for the main menu in a WordPress template?
- how to wrap tag in tag html to wordpress menu conversion
- How to add categories to wp_list_pages()
- Second menu not showing
- menu behavior is not as expected
- Part of Menu Item Hidden on Header Menu
- which is the best way to customize nav-menu-template.php?
- Arguments ignored/markup changed in wp_nav_menu if no menu is selected
- Create wordpress header with custom logo in between the menu splitting the menu into two equal parts [closed]
- Multiple WordPress Menus that will only display all pages
- Menu item added in wp_nav_menu_items filter is never highlighted
- WordPress empty Nav Menu error
- Single-level menu option? Another way?
- Problem with empty class attributes when running a filter on nav_menu_css_class
- How to append to menu items selectively
- Custom Nav Walker Trouble
- How to set the currently active page in the menu including parents
- Issue on Adding A Class to Bootstrap Navbar Walker Dropdown
- Show woocommerce categories on my theme menu styling
- Custom Navigation build using wp_nav_menu and walker
- Override customizer values on a per-menu base
- Child Theme header1.php file not overwriting parent theme’s header1.php file
- Why wp_nav_menu() doesnt show the proper meny when invoked two consecutive times?
- How to develop a menu like wwe.com?
- 3 Level Deep Navigation Menu Not Showing All Levels
- Why are some of my menu items not displaying on my menu?
- How to add menù section to my WordPress template?
- How can i make multilevel menu in wordpress theme with bootstrap
- How to modify mobile nav menu text in theme
- Adding content inside the anchor tags within WordPress main nav
- Why is my container argument not working for wp_nav_menu() [closed]
- Theme development: menu links a tabbed page with page jumps
- How to Emulate Default Navigation Menu Behaviour in a Custom Theme?
- How do I implement jPanelMenu?
- Does wordpress add their own classes into nav menus?
- Custom menu: Link names
- Remove the Tag from wp_nav_menu
- Why do sticky posts show in this menu?
- Making a horizontal flyout menu from WordPress category listing
- how to create/register menu items that can be added to menus later
- Why nav_menu_css_class doesn’t work with apply_filters?
- White screen of death on index.php page 3 and above?
- Use instead of for wp_nav_menu()
- Pages not displaying as sections on static page
- Menu names not getting translated
- Nav menus Fast previewing not working with wp_get_nav_menu_items!
- wp_nav_menu custom walker class
- How to add custom nav_menu_css_class to certain menu only?
- How to add custom field option with menu?
- Strict Standards Error bootstrap navwalker
- Main Menu Theme Different Output Print
- Menu item not created on theme activation
- How do I move menu to the bottom in Custom Community theme?
- Creating Multiple Menus in the Thesis Theme?
- How do I middle-align my header menu items in WordPress [closed]
- Fatal error: Call to undefined function the_posts_navigation()
- Bootstrap 4 mobile menu not working for WordPress Development
- 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]