Use the has_nav_menu to detect if the menu is configure in a body_class filter.
Something like
add_filter( 'body_class', 'wpse209469_body_class' );
function wpse209469_body_class( $classes ) {
if (has_nav_menu('primary-menu'))
$classes[] = 'primary-menu';
return $classes;
}
If you have two menus you can change the condition to match both, or just do two filters. There is probably a way to enumerate all the menus and add classes for them but it is probably an overkill.
Related Posts:
- wp_nav_menu: show menu only if one exists, otherwise show nothing
- Making breadcrumb with wp_nav_menu
- Renaming a WordPress Admin Menu
- Deleted pages are NOT removed from custom menus?
- How to add active class on current menu item page?
- Add Page ID class to nav menu items
- Way to bulk delete menu items in new 3.x Appearance > Menus system?
- WordPress nav_menu_link_attributes Not Working
- Customize the menu by adding items
- menu entries are lost
- Nav Menu and display post count
- Automatically Add New Tags to Sub-menu
- wp_nav_menu log in/out link?
- Accesibility problems with dropdown menus in twentyten theme or others
- Error “The given object ID is not that of a menu item” on menu with 40+ items
- Theme menu in Admin Panel
- How to target children of child pages
- How to insert custom code into wp_nav_menu structure?
- Adding post excerpt into navigation menu
- Editing WordPress Nav Menu Walker
- How to create a Menu based a username
- How to add php to custom link in the nav menu? [closed]
- Did upgrading from 3.3 to 3.3.1 introduce breaking changes in the menu navigation?
- Operable default menu *and* custom 3 menu
- WordPress menu permalink redirects to wrong page
- HTML to WordPress Menu convert
- Remove current class from sub menu items
- How to change menu URLs to hashes?
- How do I render a navigation menu like my theme does?
- WordPress Menu Prepends URL To My Anchors
- How to handle many different menus?
- Check if menu_item has children or has parent
- Why is wordpress forcing https link generation?
- pull non-wp site into content area of wordpress -or- pull wp header into non wp site?
- cross-site custom menu
- How to remove the HOME menu item
- Adding menu items?
- How to get rid of the home link in nav menu?
- How to truncate menu label in wordpress?
- display menu as table layout
- How to change the location of the menu
- How can I make a menu link visible only to admins (without plugins)?
- magic “MENU” button under Twenty Twelve theme
- Remove first separator in wp_nav_menu
- change hover color of specific menu link [closed]
- How can I make a WordPress sub-menu with a top-level that isn’t clickable?
- WordPress classes removed when using custom walker
- Get parents child pages
- menu-item class missing on wordpress menu
- Show subpages of a category in a custom menu
- how to add home icon instead of text in wordpress menu
- Active class to current link
- Making pages in a menu appear conditionally
- How to add a menu that belongs to parent blog to all child-blogs?
- How to create this kind of sub-menu in new line?
- How to use wp_list_pages on a grandparent page
- How to add social buttons like facebook and twitter in the footer of a theme?
- Dropdown primary navigation menu not working
- Understanding with this WordPress code
- Link after WordPress
- When created sub-directory, can we create a new navbar?
- How to add an archive page to WordPress menus (nav_menu)?
- Misleading behaviour on Menu & Theme location
- Add category label for appearance > menus items
- Custom items for Menus
- Menu flickering with each refresh on Google Chrome [closed]
- Remove Double Menu in Mobile View and Have one Menu Only
- calling JS to custom menu design
- WP pages content is missing in frontend
- How i can get current menu id with multiple occurrence
- How to get rid of the bottom line in the navigation menu via CSS file?
- Active menu item state on all menu items
- Dashicons not showed for admin menu
- How to select particular menu position in wordpress?
- Error: Declaration of MyClass::start_lvl() should be compatible with that of Walker_Nav_Menu::start_lvl()
- Installing compact search in the main menu?
- Having an issue with wp_nav_menu displaying custom navigation
- Add dynamic content block to nav section generated by custom walker
- Menu administration, how to allow special charachters
- How to avoid website url appending problem in wp site?
- Create custom page and custom menu
- Get first menu item of custom menu
- How can I modify wp_nav_menu with walker?
- menu items outside of blog
- Bought custom navigation menu from codecanyon, how to change feature.php?
- Custom menu linking to page not found
- How to insert date in topNav
- Change sub-menu css class
- Somehow lost my MENU from my home page- help!
- How to completely remove the top section with the menu?
- How To Conditionally Change Menu In Same Theme Location
- How to display a submenu as a popup when clicking a button?
- Not even able to Log in [closed]
- how can i get the page_ID in nav li [closed]
- How do i add logo in wordpress studiopress (glam theme)?
- register_nav_menus and wp_nav_menu issue, not displaying independent menus
- Convert a custom bootsrap based menu to wordpress nav walker
- How do I get the menu items based on name or ID?
- Menu problem : when add wordpress element in menu it convert into empty custom link
- Problems with the navigation menu