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=' );