pre_insert_term
Filters a term before it is sanitized and inserted into the database.
Usage
add_filter( 'pre_insert_term', 'wp_kama_pre_insert_term_filter', 10, 3 ); /** * Function for `pre_insert_term` filter-hook. * * @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(). * * @return string|WP_Error */ function wp_kama_pre_insert_term_filter( $term, $taxonomy, $args ){ // filter... return $term; }
- $term(string|WP_Error)
- The term name to add, or a WP_Error object if there's an error.
- $taxonomy(string)
- Taxonomy slug.
- $args(array|string)
- Array or query string of arguments passed to wp_insert_term().
Changelog
Since 3.0.0 | Introduced. |
Since 6.1.0 | The $args parameter was added. |
Where the hook is called
pre_insert_term
wp-includes/taxonomy.php 2353
$term = apply_filters( 'pre_insert_term', $term, $taxonomy, $args );