delete_term_relationships
Action HookDescription
Fires immediately before an object-term relationship is deleted.Hook Information
File Location |
wp-includes/taxonomy.php
View on GitHub
|
Hook Type | Action |
Line Number | 3045 |
Hook Parameters
Type | Name | Description |
---|---|---|
int
|
$object_id
|
Object ID. |
array
|
$tt_ids
|
An array of term taxonomy IDs. |
string
|
$taxonomy
|
Taxonomy slug. |
Usage Examples
Basic Usage
<?php
// Hook into delete_term_relationships
add_action('delete_term_relationships', 'my_custom_function', 10, 3);
function my_custom_function($object_id, $tt_ids, $taxonomy) {
// Your custom code here
}
Source Code Context
wp-includes/taxonomy.php:3045
- How this hook is used in WordPress core
<?php
3040 *
3041 * @param int $object_id Object ID.
3042 * @param array $tt_ids An array of term taxonomy IDs.
3043 * @param string $taxonomy Taxonomy slug.
3044 */
3045 do_action( 'delete_term_relationships', $object_id, $tt_ids, $taxonomy );
3046
3047 $deleted = $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_tt_ids)", $object_id ) );
3048
3049 wp_cache_delete( $object_id, $taxonomy . '_relationships' );
3050 wp_cache_set_terms_last_changed();
PHP Documentation
<?php
/**
* Fires immediately before an object-term relationship is deleted.
*
* @since 2.9.0
* @since 4.7.0 Added the `$taxonomy` parameter.
*
* @param int $object_id Object ID.
* @param array $tt_ids An array of term taxonomy IDs.
* @param string $taxonomy Taxonomy slug.
*/
Quick Info
- Hook Type: Action
- Parameters: 3
- File: wp-includes/taxonomy.php
Related Hooks
Related hooks will be displayed here in future updates.