I'm trying to use wp_nav_menu to only display a menu if one exists, otherwise, display nothing.
If I delete the menu, it will output a list of the pages.
Here's the code I've unsuccessfully tried:
<?php
if ( has_nav_menu( $theme_location ) ) {
// User has assigned menu to this location;
// output it
wp_nav_menu( array(
'theme_location' => $theme_location,
'menu_class' => 'nav',
'container' => ''
) );
}
?>
My functions.php file contains:
if (function_exists('register_nav_menus')) {
register_nav_menus (
array('main_nav' => 'Main Navigation Menu'));}
How can I use wp_nav_menu to only display a menu if one exists, otherwise show nothing?