Which function should I use to programatically delete WordPress menu items?
As of this writing, there is no specific function in WordPress for deleting a menu item.
However, since menu items in WordPress are treated as posts, you can use the wp_delete_post() function, as shown below.
How to programatically delete menu items in WordPress
The code below shows how to delete a menu item in WordPress:
/*
$id is the post id of the menu item you want to delete
if you have a menu item array provided by the REST API, this ID will be in $item['menu-item-db-id'].
If your menu item object came directly from the database, the ID can be found in $item->ID
*/
$id = $item->ID; //or $item['menu-item-db-id'] -- see comment above
wp_delete_post($id);
Unlike other functions that operate on posts, wp_delete_post() must be passed a numeric ID, rather than a post object.