_wp_delete_tax_menu_item

Serves as a callback for handling a menu item when its original object is deleted.

Description

_wp_delete_tax_menu_item( (int) $object_id, (int) $tt_id, (string) $taxonomy ); 

Parameters (3)

0. $object_id — Optional. (int)
The ID of the original object being trashed. Default 0.
1. $tt_id (int)
Term taxonomy ID. Unused.
2. $taxonomy (string)
Taxonomy slug.

Usage

  1. if ( !function_exists( '_wp_delete_tax_menu_item' ) ) { 
  2. require_once ABSPATH . WPINC . '/nav-menu.php'; 
  3.  
  4. // Optional. The ID of the original object being trashed. Default 0. 
  5. $object_id = -1; 
  6.  
  7. // Term taxonomy ID. Unused. 
  8. $tt_id = -1; 
  9.  
  10. // Taxonomy slug. 
  11. $taxonomy = ''; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = _wp_delete_tax_menu_item($object_id, $tt_id, $taxonomy); 
  15.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/nav-menu.php  
  1. function _wp_delete_tax_menu_item( $object_id = 0, $tt_id, $taxonomy ) { 
  2. $object_id = (int) $object_id; 
  3.  
  4. $menu_item_ids = wp_get_associated_nav_menu_items( $object_id, 'taxonomy', $taxonomy ); 
  5.  
  6. foreach ( (array) $menu_item_ids as $menu_item_id ) { 
  7. wp_delete_post( $menu_item_id, true );