1

I have several menus in my theme, but if I don't create menu in dashboard, then in those menus is displayed default menu. How can I avoid that? I don't want any menu content until I create one.

This is my code:

<?php wp_nav_menu(array('theme_location' => 'main_menu_4', 'depth' => 1));?>
0

Use the fallback_cb argument of wp_nav_menu():

(callable|bool) If the menu doesn't exists, a callback function will fire. Default is 'wp_page_menu'. Set to false for no fallback.

<?php
wp_nav_menu( array( 
    'theme_location' => 'main_menu_4',
    'fallback_cb'    => false
    'depth'          => 1, 
) );
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.