Default Wordpress menu content

admin2025-06-07  48

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));?>

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));?>
Share Improve this question asked Oct 21, 2018 at 12:40 DamianDamian 971 gold badge1 silver badge11 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 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, 
) );
?>
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749245032a317571.html

最新回复(0)