Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I know that each menu item is simply post present in nav_menu_item post type. It has has ID and can be removed with wp_delete_post() but posts deleted this way don't remove menus present under [Appearance > Menus]. Only menu items are removed.

For instance I have "My Menu" under [Appearance > Menus] that has the following items: page-1, page-2, category-3. I can remove menu items with wp_delete_post() but "My Menu" (group for those items) remains intact.

How can I programatically remove all defined Menus (and menu items)?

share|improve this question
1  
It’s quite easy to interpret this question in many different ways. Any chance of posting a screenshot of what you’re trying to accomplish? –  Cor van Noorloos Dec 16 '12 at 13:15
    
I added example. Basically, under [Appearance > Menus] I can create menu that has items. Items can be removed with wp_delete_post() but this doesn't remove "Menu Group" that they were in. –  Paul Dec 16 '12 at 16:08
add comment

1 Answer 1

up vote 0 down vote accepted

Please check wp_delete_nav_menu() function. If you want to get all nav menus you can check wp_terms table or

$menu_list = get_terms('nav_menu');

to get a list of it.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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