Assuming that you have custom Nav Menus implemented properly:
-
Registering nav menu Theme Locations:
register_nav_menus( array( 'parent_page' => "Parent Page", 'page_a' => "Page A", 'page_b' => "Page B", //etc ) );
-
Calling
wp_nav_menu()
correctly:wp_nav_menu( array( 'theme_location' => 'page_a' );
…then you can use the has_nav_menu()
conditional to determine if a Theme Location has a menu assigned to it:
if ( has_nav_menu( 'page_a' ) ) {
// do something
}
In your specific case, you could do something like so:
if ( has_nav_menu( 'page_a' ) ) {
wp_nav_menu( array( 'theme_location' => 'page_a' ) );
} else {
wp_nav_menu( array( 'theme_location' => 'parent_page' ) );
}
Related Posts:
- How to add posts to custom menus?
- wp_nav_menu(), how to change class?
- Display Menu Name using wp_nav_menu
- How can I display a menu on certain pages only?
- Add custom classes to anchor in wp_nav_menu
- Add Caret to Menu Items with Sub-Menus in WordPress Theme
- wp_nav_menu sort order?
- How to use logout function on custom menu link?
- How to display wp_nav_menu() conditionally only when not on a 404 page?
- Problem with registering menus – What to do when other solutions aren’t working?
- Add a #hash to the links in my custom menu
- How can i change menu link when page content empty?
- Select menu on browser resize
- How to add (css) classes to only one wp_nav_menu()?
- Displaying wp menus by name without using theme locations
- How to add nofollow to wp_nav_menu
- How do I add a post to a menu
- how to change WordPress menu markup/classes
- WordPress nav_menu_css_class theme filter is not being called
- Best practices: Custom theme sidebar menu – hardcode or widget?
- Custom Nav Walker Displaying Values in Sub Menu
- Create self-populating menu and add extra divs to the menu layout
- 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 remove class attributes from custom menu markup?
- 2 differen’t menus and it’s using same items in both
- menu behavior is not as expected
- Is there an action for save_menu and/or update_menu?
- Set default screen option for appearance -> menus
- Part of Menu Item Hidden on Header Menu
- wp_nav_menu add something before closing container and after last list item
- Find the Children of a Page then Echo it as a Bulleted List of Links (menu)
- which is the best way to customize nav-menu-template.php?
- WordPress navbar with logo in middle [closed]
- WordPress is adding margins and padding to my custom menu?
- Menu item added in wp_nav_menu_items filter is never highlighted
- wp_post->post_parent object returning 0
- multisite: global menu containing network site links?
- How to make theme elements customizable in wordpress?
- 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?
- Where am I doing wrong in my theme menu?
- Custom Navigation build using wp_nav_menu and walker
- Why does has_nav_menu return false when get_registered_nav_menus shows the opposite?
- Recommended method for updating/adding menus when adding new theme
- Admin: sub menu doesnt display under apperance when activate my themes
- 3 Level Deep Navigation Menu Not Showing All Levels
- How to Create custom xml file for demo content for custom theme?
- How should I use starter content utility to show some default menus?
- How to create and populate with few links a menu in child theme functions.php?
- Second menu has the first menu ID
- wp_nav_menu and its fallback
- Thesis -style Navigation
- Theme development – Automatically menu creation
- how do i develop a global nav and local nav to be wordpress dynamic?
- Theme development: How to add CSS classes to menu items?
- Navbar- disable “onClick” drop-down
- Why is my container argument not working for wp_nav_menu() [closed]
- Some doubts about WordPress handle the horizontal main menu visualization
- How to conditionally add a wp_filter
- Remove/Hide a Widget on a Custom Template
- Custom nav menu not showing
- Parent/Child pages
- .current_page_ancestor broken in Twenty Eleven
- finding menu hierachy > wp_get_nav_menu_items
- How to substitute old wordpress menu by wp 3 menu the right way?
- if (has_custom_menu())?
- Making a horizontal flyout menu from WordPress category listing
- Archives and Categories in Custom Menu
- WordPress custom menu can’t show 3. level submenu
- Best way to give user the option to make a menu, mega menu?
- Programatically Created Menu not Editable in Dashboard
- Building a custom menu or use a plugin?
- 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?
- Cold Fusion to WordPress
- Menu is in Reversed order
- WordPress Menu item > Sub menu Class update
- Nav menus Fast previewing not working with wp_get_nav_menu_items!
- How to know and change the machine name of a menu?
- Need help with adding custom wordpress menu and sub-menu
- WordPress menu walker – Get parent item text inside end_lvl function
- How to achieve this navigation style in wordpress navigation
- HTML TO WP Theme : Submenu goes down wp_nav_menu
- After theme change the menus have to be manually linked to the corresponding theme location
- Horizontal Navigation
- What’s the policy for building a theme that doesn’t support widgets/menus?
- Problem with multiple menus in theme
- Main Menu Theme Different Output Print
- Menu item not created on theme activation
- How can I change the title of the Home link in the navigation bar?
- How do I move menu to the bottom in Custom Community theme?
- Header links also appearing in the footer
- Creating Multiple Menus in the Thesis Theme?
- How do I middle-align my header menu items in WordPress [closed]
- How to highlight current menu bar base on the URL?
- Global Navigation menu in diiferrent wordpress setups
- Add wrapper for a specific sub-menu
- Dynamic nav menu with icons [closed]