The following example adds a unique CSS class to a single, specific nav menu item.
function my_special_nav_class( $classes, $item ) {
if ( is_single() && $item->title == 'Blog' ) {
$classes[] = 'special-class';
}
return $classes;
}
add_filter( 'nav_menu_css_class', 'my_special_nav_class', 10, 2 );
Related Posts:
- Using a menu walker add a custom item at the end of the menu’s items
- Add settings to menu items in the Customizer
- WordPress Shortcode in Menu Item Title
- Show current navigation path from menu
- Menu items (all menus) being deleted randomly on their own [duplicate]
- Put a wp_nav_menu inside another one
- different Menu position showing same menu
- How to add bubble count in WordPress wp_nav_menu menu?
- Add class to active top level (grandparent) menu item
- WordPress wp_nav_menu within iFrame
- Check if wp_nav_menu items have submenus
- wp_nav_menu doesn’t generate parent/ancestor classes
- WP_nav_menu fallback not working
- How to conditionally register nav menus with advanced custom fields?
- Use walker for specific menu, or avoid use of walker
- Change where navigation bar links?
- How to give custom classes to the WordPress Menu widget
- No “current-menu-ancestor” class added when browsing an archive page
- Does wp_nav_menu use the gettext filter?
- How to add #navbar to all page links?
- Problems Displaying Multiple WP Menus
- View h2 content tags of a page in sub menu
- How to add custom classes to more than one separate menu’s a link in wordpress?
- Change an li class name in a wordpress custom menu walker
- Custom walker nav – Add sequential number as class
- add_submenu_page function to show videos table
- Menu item with no page, but with dropdown
- How to test if blog page is active
- WordPress Custom Menus Issue
- Side Menu Icon Expandable
- wordpress responsive menu not dropping down
- WordPress Plugin menu position overwrite other item
- WP custom nav menu problem
- Show WordPress Menu On External Site
- WordPress default menu in database
- If menu has submenu, add parent as first child
- Create custom page and add it in nav menu by code
- Two-tone menu items
- How to highlight 1st level menu item based on actual page
- Admin-ajax.php 500 error when Add to menu is clicked in admin
- replace existing menu programtically
- Submenu page buttons are blank
- Submenu items not showing anymore on the navigation
- superfish.js seems it is not working properly after wordpress upgarde to 4.6.1
- How to add an attribute data-slug = “$specfic_page_slug” in WordPress menu item?
- How to add a page to header that is outside of WordPress?
- Get current menu item label for specific parent menu [closed]
- Theme only supports one menu? [closed]
- Problem adding ‘has-children’ class to wp_nav_menu
- set certain item in nav walker to active when on archive pages or singles
- Mobile screen does not display Primary navbar…just a three line icon [closed]
- How do I enable “metaboxes” by default in menu editor?
- The cart, checkout, and shop links not getting removed
- Creating menu always gives error A name is required for this term
- Using Different wp_nav_menu theme_location based on page id (or a parent id)
- Display Menu Navigation Label
- Menu is not displaying on the site navigation [closed]
- Creating custom menu with custom themes
- Expected snippet value not showing
- Wp Nav Menu div containers
- Updated WordPress, now Navigation is Messed Up
- Add posts from a category to menu with all posts in it as sub menu
- How to show only current item children using wp_nav_menu?
- Possible to append class to nav menu added to widget area?
- Page dependent sub-menu?
- Copied site has wrong menu URL behaviour
- Removing wp admin menu item on top bar of admin backend
- Error: Declaration of MyClass::start_lvl() should be compatible with that of Walker_Nav_Menu::start_lvl()
- Nav_walker add id to dropdown ul
- Navbar is hidden behind carousel when using wp-boostrap-navwalker
- WordPress nav-menus not finding page
- Primary menu items are dissapearing
- Active Current Menu – Adding class to child theme
- display cart information within li of cart menu item
- WPML CMS Nav and Custom Nav_Walker Undefined Property Notices [closed]
- Add data-track to links in menu
- Is it possible to seperate wordpress menu by different div?
- How to add odd and even classes to all nav links through walker?
- Output sort number in wp menu list item?
- Check in walker if current page is descendant
- Add a non-dynamic phrase/character after a page title?
- how to display wordpress navbar with top menu outside wordpress system
- Active page link not getting class assigned
- Removing menu item doesn’t get removed on edit post
- change link of menu particular tab
- Next page link via the custom menu
- Customize Walker_nav_menu to show posts if item is category
- Top menu link anchor href value change after online server?
- Menu not always using correct link
- Add Protocol to Custom Menus
- How to handle change the appearance of ‘categories’ box on dashboard?
- How can I stop wp_nav_menu from returning extraneous root links?
- How to add posts with thumbnails to my dropdown menu?
- Menu System: Custom Links
- can anyone help me converting my static menu to wp_nav_menu I’am trying to add static menu item to WordPress Menu
- Formatting WordPress Menus (without bullets, inline with text)
- Change Menu Order
- Two Homes In Navigation Menu
- Theme supports only one menu. I need to add more – but how? [closed]
- How to replicate a mobile menu from a site to a wordpress site [closed]