0

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

  • 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? – user5424 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
0

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.

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.