Filter hook 'term_exists_default_query_args'

in WP Core File wp-includes/taxonomy.php at line 1625

View Source

term_exists_default_query_args

Filter Hook
Description
Filters default query arguments for checking if a term exists.

Hook Information

File Location wp-includes/taxonomy.php View on GitHub
Hook Type Filter
Line Number 1625

Hook Parameters

Type Name Description
array $defaults An array of arguments passed to get_terms().
int|string $term The term to check. Accepts term ID, slug, or name.
string $taxonomy The taxonomy name to use. An empty string indicates the search is against all taxonomies.
int|null $parent_term ID of parent term under which to confine the exists search. Null indicates the search is unconfined.

Usage Examples

Basic Usage
<?php
// Hook into term_exists_default_query_args
add_filter('term_exists_default_query_args', 'my_custom_filter', 10, 4);

function my_custom_filter($defaults, $term, $taxonomy, $parent_term) {
    // Your custom filtering logic here
    return $defaults;
}

Source Code Context

wp-includes/taxonomy.php:1625 - How this hook is used in WordPress core
<?php
1620  	 * @param string     $taxonomy    The taxonomy name to use. An empty string indicates
1621  	 *                                the search is against all taxonomies.
1622  	 * @param int|null   $parent_term ID of parent term under which to confine the exists search.
1623  	 *                                Null indicates the search is unconfined.
1624  	 */
1625  	$defaults = apply_filters( 'term_exists_default_query_args', $defaults, $term, $taxonomy, $parent_term );
1626  
1627  	if ( is_int( $term ) ) {
1628  		if ( 0 === $term ) {
1629  			return 0;
1630  		}

PHP Documentation

<?php
/**
	 * Filters default query arguments for checking if a term exists.
	 *
	 * @since 6.0.0
	 *
	 * @param array      $defaults    An array of arguments passed to get_terms().
	 * @param int|string $term        The term to check. Accepts term ID, slug, or name.
	 * @param string     $taxonomy    The taxonomy name to use. An empty string indicates
	 *                                the search is against all taxonomies.
	 * @param int|null   $parent_term ID of parent term under which to confine the exists search.
	 *                                Null indicates the search is unconfined.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 4
  • File: wp-includes/taxonomy.php
Related Hooks

Related hooks will be displayed here in future updates.