[wp-trac] [WordPress Trac] #31051: Programmatically delete nav menu item

WordPress Trac noreply at wordpress.org
Mon Jan 19 12:25:23 UTC 2015


#31051: Programmatically delete nav menu item
-------------------------+-----------------------------
 Reporter:  virgodesign  |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Menus        |    Version:  4.1
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 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:

 [http://wordpress.stackexchange.com/questions/60872/how-do-i-delete-not-
 exclude-a-menu-item-from-navigation-bar]

 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.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/31051>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list