Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#31051 closed enhancement (duplicate)

Programmatically delete nav menu item

Reported by: virgodesign's profile virgodesign Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.1
Component: Menus Keywords:
Focuses: Cc:


It seems that does not exist a direct fuction for deleting a nav menu item programmatically, using php.
Something such as wp_delete_nav_menu_item, a function that would delete a nav menu item from the database, correctly and definitely.

There is a question partially answered here:

Using wp_delete_post seems to be a workaround, as it will not update correctly all the databases entries that are involved.

Maybe a working solution could be:

  1. Delete the nav menu item from wp_posts using wp_delete_post (the 8 postmeta options involved will be also deleted).
  2. Delete the nav menu item from wp_term_relationships.
  3. Update the counter of the nav menu in wp_term_taxonomy.

I'm not sure if I'm missing something else, but I think this could be a staritng point. Any suggestions or comments would be very appreciated.

Change History (2)

#1 @tyxla
9 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #29728.

#2 @SergeyBiryukov
9 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.