Use has_nav_menu()
e teste para theme_location
, em vez de menu_id
:
<?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' => ''
) );
}
?>
Você pode gerar conteúdo alternativo adicionando uma cláusula else
.
EDITAR
Você precisa substituir $theme_location
com seu real theme_location
:
<?php
if ( has_nav_menu( 'main_nav' ) ) {
// User has assigned menu to this location;
// output it
wp_nav_menu( array(
'theme_location' => 'main_nav',
'menu_class' => 'nav',
'container' => ''
) );
}
?>