I’m guessing your menu contains only Pages (posts of the page
type) on your site?
But nonetheless, with wp_nav_menu()
, if you specify a theme_location
that doesn’t exist or contains no menu (i.e. no menus assigned to that location), then the fallback_cb
arg (which defaults to wp_page_menu()
) will determine what is displayed.
So if you want the function to display the menu only if it’s assigned to the specified theme location, you can do the has_nav_menu()
check:
if ( has_nav_menu( 'menu-ID1' ) ) {
wp_nav_menu( 'theme_location=menu-ID1' );
}
or set the fallback_cb
to an empty string:
wp_nav_menu( array(
'theme_location' => 'menu-ID1',
'fallback_cb' => '',
) );
// or you may pass the function args as a query string:
wp_nav_menu( 'theme_location=menu-ID1&fallback_cb=' );
Related Posts:
- Is there an easy way to replace a custom menu link with a page or post?
- Add Javascript to WordPress Menu
- Filter wp_nav_menu()
- Show just one level of child pages, wp_list_pages woe
- Use navigation path from menu for permalink
- add span class inside wp_nav_menu link anchor tag
- How to set limit only on top levels of wp_nav_menu?
- Show only 2nd level of navigation depending on active navigation
- How to get a different mobile menu than desktop menu in the twentytwelve child theme
- HTML Bootstrap navigation menu to WordPress menu using wp_nav_menu
- How to manually add an item to a submenu in a menu generated by wp_nav_menu?
- WordPress Export Import Site Navigation Menu
- Using Image Links in WordPress Navigation Menus Instead Of Text Links
- Bar separated navigation by extending Walker_Nav_Menu
- Replace menu tag with tag
- How to style current page menu item when using a walker
- Adding different classes to anchor in navigation menu
- Add Bootstrap dropdown class to a nav menu
- Search box as a menu item in the nav menu output by wp_nav_menu?
- How can I put two menus in the same div?
- BuddyPress – How to add logout in nav menu
- Second nav is merged with the first in mobile
- Nav Walker current menu item not displaying
- Using Shortcodes in WP-Menus in WP 3.1 (via nav_menu_objects)?
- Navigation (wp_nav_menu) refuses to nest within parent element
- Add custom menu item metabox in Navigation Settings
- Auto add pages to primary menu with functions.php
- Get admin menu link
- Hide Menu Unless Logged In
- how to remove the top navigation bar or header top on wordpress website?
- Highlight another nav item
- How to change theme header to support multiple nav menus?
- how can i add css class on current page in wordpress wp_nav_menu
- How to rewrite the output of wordpress nav menu?
- How to have the Header show different content on different pages?
- Programmatically add existing pages and subpages to Appearance Menu
- I want to hide the navigation menu on a particular page
- walker – 0 level on submenu formatting
- Static page to one page- menu inactive items highlighted
- automatically append menu parent as first item in submenu with nav_walker
- wp_nav_menu() doesn’t work
- Remove nav menu item by script
- Help with walker for nav
- Make a navigation menu in the same post [duplicate]
- Get menus created with menu editor?
- How to create a menu with pages and post categories?
- remove specific classes from menu items
- Missunderstanding of WordPress menus
- How to add schema.org SiteNavigationElement and property URL to navbar?
- Theme Location empty
- how to remove description from menu buttons?
- How to buid wordpress menu with auto width sub-menu items in dropdown menu without any items sharing one line [closed]
- Adding toggle-able element after menu item
- Remove a class from a using Walker
- Make two bootstrap menus collapse into one dropdown
- Add custom link on the fly to nav menu
- wp_bootstrap_navwalker Fatal Error
- Custom register_taxonomy ins’t showing custom Nav menu
- Conditional menus based on page title
- How to test if a specific page is the front page?
- Style wp_link_pages as a select drop down list
- Mobile navigation is shown, but standard navigation does not disappear
- changing the labels inside appearance -> menus for some for the fields
- Costum walker with sub menu item count
- How do I add 3rd level of dropdowns to wp_nav_menu array?
- WP Menu Rollover Nav Item and Effect DIV Elsewhere
- How to change the navigation menu
- Add/remove image from navigation bar
- WordPress nav_menu items from another menu appearing
- How can I order these pages in this navigation bar on this old wordpress theme?
- WordPress Menu Navigation links not working
- Where to place a svg chevron down in my custom walker?
- How to apply individual menu item’s “CSS Classes” to , not ?
- Add href to tag in nav menu for mobile
- Output existing wp_nav_menu with a custom walker
- how to split vertical menu into two columns using walker nav menu
- Sub-Items Not Visible in Navigation
- How can I create this menu with wp_nav_menu()?
- Unable to remove page from primary menu
- Show navigation header menu by post and categery
- How to Use Default Auto-Generated Menu?
- wp-nav menu with custom walker , how to remove a tag if it has any submenu
- Menu Details Output in Javascript [closed]
- Custom location for menu
- Can’t add optional class to menu item when using Walker_Nav_Menu
- nav_menu: how to force a subpage switching on the parent menu
- wp_dropdown_nav function to list menu items
- wp_nav_menu() reutrns HTTPS?
- Update nav menu item position programmatically
- Navigational error
- Determine if a navigation item has children
- wordpress superfish dropdown menu
- Unable to edit Navigation bar
- Display Username as parent menu item
- How to add or remove borders in navigation menu?
- Site pages show the page title under navigation bar
- Navigation menu, remove item from desktop
- Wrapping my ‘s with
- Navigation menu displays permalinks
- Tried to hide navigation menu on one page ended up SCRAMBLING the navigation menu on another