terms_pre_query filter-hookWP 5.3.0

Filters the terms array before the query takes place.

Return a non-null value to bypass WordPress' default term queries.

Usage

add_filter( 'terms_pre_query', 'wp_kama_terms_pre_query_filter' );

/**
 * Function for `terms_pre_query` filter-hook.
 * 
 * @param array|null $terms Return an array of term data to short-circuit WP's term query, or null to allow WP queries to run normally.
 *
 * @return array|null
 */
function wp_kama_terms_pre_query_filter( $terms ){

	// filter...
	return $terms;
}
$terms(array|null)
Return an array of term data to short-circuit WP's term query, or null to allow WP queries to run normally.

Changelog

Since 5.3.0 Introduced.

Where the hook is called

WP_Term_Query::get_terms()
terms_pre_query
wp-includes/class-wp-term-query.php 776
$this->terms = apply_filters_ref_array( 'terms_pre_query', array( $this->terms, &$this ) );

Where the hook is used in WordPress

Usage not found.