I'm developing a child theme of Twenty-Thirteen for a client. My theme contains a second navigation menu properly registered through my functions.php file.

This second navigation menu is fully working properly and just as expected.

However, as part of my design, I only want this second navigation menu to be a "single-level" menu; i.e., no children or sub-menu items.

I am able to remove any appearance of children menu items with CSS using a display:none targeting the appropriate .sub-menu item under this custom menu.

However, even though I have removed the visual possibility of sub-menu items breaking the layout, I'd like to stop the Admin from creating them in the first place. I don't want the client to add sub-menu items only to find they're not showing up. For nothing else, I'd like to produce a more robust theme, front to back.

I've searched Google, SO, SE, and the Wordpress site, but I cannot find out how I can block the creation of sub-menu items from the Dashboard. The research issue is stymied because no matter which search terms I use, I keep finding posts about people having the opposite problems... how to create a submenu.

I already have my own Dashboard page for custom theme options. Is there a way to customize the menu editing screen just for this one menu? A hook? Another idea for forcing a single-level menu?

1 Answer 1


It's not exactly what I wanted but it's very close.

As per the codex for wp_nav_menu()...

(integer) (optional) How many levels of the hierarchy are to be included where 0 means all. -1 displays links at any depth and arranges them in a single, flat list.
Default: 0

So I did this...

        'container_class' => 'menu-top-menu-container',
        'theme_location' => 'secondary',
        'depth' => -1 

I tried 'depth' => 1 to designate a pure single level, however, this does not prevent the creation of submenu items in the Dashboard. The end result is the same as my CSS hack. The Admin would not know why his new submenu items are not showing up.

I ended up using 'depth' => -1, which forces all menu items to a single level, including any submenu items that might be created. At least the Admin should notice what's going on here when he sees his submenu item show on the same level as everything else.

I'm still curious about anything that can be done to tweak the menu editing screen in the Dashboard without having to edit the core Wordpress files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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