wp_insert_term_data
Filter HookDescription
Filters term data before it is inserted into the database.Hook Information
File Location |
wp-includes/taxonomy.php
View on GitHub
|
Hook Type | Filter |
Line Number | 2582 |
Hook Parameters
Type | Name | Description |
---|---|---|
array
|
$data
|
Term data to be inserted. |
string
|
$taxonomy
|
Taxonomy slug. |
array
|
$args
|
Arguments passed to wp_insert_term(). |
Usage Examples
Basic Usage
<?php
// Hook into wp_insert_term_data
add_filter('wp_insert_term_data', 'my_custom_filter', 10, 3);
function my_custom_filter($data, $taxonomy, $args) {
// Your custom filtering logic here
return $data;
}
Source Code Context
wp-includes/taxonomy.php:2582
- How this hook is used in WordPress core
<?php
2577 *
2578 * @param array $data Term data to be inserted.
2579 * @param string $taxonomy Taxonomy slug.
2580 * @param array $args Arguments passed to wp_insert_term().
2581 */
2582 $data = apply_filters( 'wp_insert_term_data', $data, $taxonomy, $args );
2583
2584 if ( false === $wpdb->insert( $wpdb->terms, $data ) ) {
2585 return new WP_Error( 'db_insert_error', __( 'Could not insert term into the database.' ), $wpdb->last_error );
2586 }
2587
PHP Documentation
<?php
/**
* Filters term data before it is inserted into the database.
*
* @since 4.7.0
*
* @param array $data Term data to be inserted.
* @param string $taxonomy Taxonomy slug.
* @param array $args Arguments passed to wp_insert_term().
*/
Quick Info
- Hook Type: Filter
- Parameters: 3
- File: wp-includes/taxonomy.php
Related Hooks
Related hooks will be displayed here in future updates.