add_term_relationship
Action HookDescription
Fires immediately before an object-term relationship is added.Hook Information
File Location |
wp-includes/taxonomy.php
View on GitHub
|
Hook Type | Action |
Line Number | 2879 |
Hook Parameters
Type | Name | Description |
---|---|---|
int
|
$object_id
|
Object ID. |
int
|
$tt_id
|
Term taxonomy ID. |
string
|
$taxonomy
|
Taxonomy slug. |
Usage Examples
Basic Usage
<?php
// Hook into add_term_relationship
add_action('add_term_relationship', 'my_custom_function', 10, 3);
function my_custom_function($object_id, $tt_id, $taxonomy) {
// Your custom code here
}
Source Code Context
wp-includes/taxonomy.php:2879
- How this hook is used in WordPress core
<?php
2874 *
2875 * @param int $object_id Object ID.
2876 * @param int $tt_id Term taxonomy ID.
2877 * @param string $taxonomy Taxonomy slug.
2878 */
2879 do_action( 'add_term_relationship', $object_id, $tt_id, $taxonomy );
2880
2881 $wpdb->insert(
2882 $wpdb->term_relationships,
2883 array(
2884 'object_id' => $object_id,
PHP Documentation
<?php
/**
* Fires immediately before an object-term relationship is added.
*
* @since 2.9.0
* @since 4.7.0 Added the `$taxonomy` parameter.
*
* @param int $object_id Object ID.
* @param int $tt_id Term taxonomy ID.
* @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.