pre_insert_term
Filter HookDescription
Filters a term before it is sanitized and inserted into the database.Hook Information
File Location |
wp-includes/taxonomy.php
View on GitHub
|
Hook Type | Filter |
Line Number | 2435 |
Hook Parameters
Type | Name | Description |
---|---|---|
string|WP_Error
|
$term
|
The term name to add, or a WP_Error object if there's an error. |
string
|
$taxonomy
|
Taxonomy slug. |
array|string
|
$args
|
Array or query string of arguments passed to wp_insert_term(). |
Usage Examples
Basic Usage
<?php
// Hook into pre_insert_term
add_filter('pre_insert_term', 'my_custom_filter', 10, 3);
function my_custom_filter($term, $taxonomy, $args) {
// Your custom filtering logic here
return $term;
}
Source Code Context
wp-includes/taxonomy.php:2435
- How this hook is used in WordPress core
<?php
2430 *
2431 * @param string|WP_Error $term The term name to add, or a WP_Error object if there's an error.
2432 * @param string $taxonomy Taxonomy slug.
2433 * @param array|string $args Array or query string of arguments passed to wp_insert_term().
2434 */
2435 $term = apply_filters( 'pre_insert_term', $term, $taxonomy, $args );
2436
2437 if ( is_wp_error( $term ) ) {
2438 return $term;
2439 }
2440
PHP Documentation
<?php
/**
* Filters a term before it is sanitized and inserted into the database.
*
* @since 3.0.0
* @since 6.1.0 The `$args` parameter was added.
*
* @param string|WP_Error $term The term name to add, or a WP_Error object if there's an error.
* @param string $taxonomy Taxonomy slug.
* @param array|string $args Array or query string of 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.