Yes, they’re stored as metadata '_menu_item_classes'
for each menu item so eg (updated to use separate function)
function custom_wp_nav_menu_css_class( $classes, $item, $args, $depth ) {
$whitelist = array(
//List of allowed menu classes
'current_page_item',
'current_page_parent',
'current_page_ancestor',
'first',
'last',
'vertical',
'horizontal'
);
// Note array containing empty entry always created for menu item meta so filter out.
if ( $optional = array_filter( get_post_meta( $item->ID, '_menu_item_classes', true ) ) ) {
$whitelist = array_merge( $whitelist, $optional );
}
return array_intersect( $classes, $whitelist );
}
add_filter( 'nav_menu_css_class', 'custom_wp_nav_menu_css_class', 10, 4 );
Related Posts:
- Remove wrapping div and ul from output of wp_nav_menu
- Add custom html to last sub-menu item
- wp_nav_menu() custom container and container_id
- Show a WP 3.0 Custom Menu in an HTML Select with Auto-Navigation?
- global menus made from master site’s custom menus wpmu network
- Adding Custom Link anchors in the top menu that points to specific sections of the site home page
- wordpress custom walker for thumbnails with custom menu
- Change default status and replace the icon for an hamburger menu
- simple expandable vertical menu, java script problem
- Create a Custom menu item fetched by Product Categories and Sub Categories
- wp_nav_menu google analytics event tracking
- How to extend nav-menu-item-control data in Appearance > Customize?
- Hide Login information in Account settings in Buddy Boss
- How can I get the page url slug when ‘post_name’ returns an id?
- Adding all sub-pages to the menu manager
- add JS to multiple plugin admin pages
- Putting tag outside tag on generated Menu
- Programmatically (PHP) get the nr. of items in the primary navigation menu
- How to create left and right menu with logo center in a custom theme?
- Add clickable arrows to parent menu items with children elements e.g. with
- How Do I Remove The Right Hand Block On The Main Header?
- Adding posts to custom menu [closed]
- How to wrap the list with custom class using wp_nav_menu?
- Alphabetical Custom Menu
- Sub menu indicator that links to sub menu
- Navigation label for page in custom theme
- WPML Plugin Not displaying multilingual Menus
- how to display a specific wordpress menu?
- Create a url structure for my blogs based on categories and sub-cats
- Looking replicate static HTML Menu into WordPress Dynamic Menu [closed]
- Custom font size nav bar
- Sticky menu for WP custom menubars
- Stop Expansion of Top Level Menu in the WordPress Admin Sidebar
- Insert menu with a custom walker into page / post body using shortcode?
- Implement a Walker with custom object rather than WordPress database object
- How can I tag a menu item as visited for each unique user?
- How do I create a root link in wordpress to a PDF file?
- Position a hard-coded menu item
- How can i create menu like in the example?
- WordPress custom dropdown listings
- How to request container_class from wp_nav_menu
- Menu not appearing in custom theme
- How can i display custom menu in sidebar?
- How to have multiple WordPress Menus
- How to add active state to the navigation links?
- Missing current_page_item in custom menu
- WordPress menu: How to make www.link.com/#name never contain current_page_item class?
- Customize Widget Navigation
- Custom menu not showing even though it shows as being registered?
- Custom CSS Nav Menu Style Not Being Applied
- Current menu item highlights wrong
- Add producthunt badge to wordpress menu
- Woocommerce custom “My Account” Tab – Add Save button
- Adding a drop-down (select tag) option under Menu Settings in WordPress Admin
- How to add a template – so that i can choose a different menu for some pages
- clickable toggle menu, help
- How to create custom post type selection to nav menu
- Help needed creating a custom Hamburger menu in header
- Menu selection for header
- How to create a custom menu for specific user
- How to customize WordPress vertical menu?
- Creating a dynamic URL for an external link inside content
- remove or hide Link Relationship (XFN) form Menus tab
- My connecting URL form in html to PHP does not work
- User WordPress menu in custom page
- Adding images to anchors in the list created and fetched with wp_nav_menu
- how to hard link to the posts page?
- How do I display entries in the top menu based on conditions selected in the sidebar menu?
- Buddypress: New Tab and Page (Members Profile) [closed]
- How to work around the bug which prevents custom menus from being deleted?
- Class .current-menu-item in custom menu Walker
- menu customization
- How to move menu next to left of the search box?
- Custom CSS File wont work on second Page
- removing extra mobile menu from the header
- Custom Menu (only showing direct cildren) ACF not showing
- Rearrange elements outputted by comment_form()
- How to build custom WP admin with custom URLs
- Custom editor field displaying HTML in Visual editor
- How to set default values for options page
- Video to stretch across the entire homepage [closed]
- How can I allow access to multiple users, using the same login, at the same time?
- Does all editing of WordPress occur within the dashboard, or can we use our own text editor?
- TwentyFifteen: How can it show a different color on every post page?
- Custom login with external provider iframe and data object
- get author in blog posts?
- Widget title markup in register_sidebar
- What is theme-editor.tmp?
- Add or Create Custom Structure Tags to Permalink
- Remove welcome panel from contact form 7 page [closed]
- Do I need to instantiate the XMLRPC class or any class in another class to access its methods?
- Customizing woocommerce product page
- WordPress Using Zip code customer shop find without woocommerce plugin
- how can custom permalink structure use for specify custom post type
- Embedded Options in a Custom Metabox
- Search results load individual post in slide out div
- Show Site Name on WP login screen
- Conditional tag
- Changes to code not displaying
- Has the table name in SQL for WordPress changed from WP_posts to WPCS_post?