terms_pre_query хук-фильтрWP 5.3.0

Filters the terms array before the query takes place.

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

Использование

add_filter( 'terms_pre_query', 'wp_kama_terms_pre_query_filter', 10, 2 );

/**
 * 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.
 * @param WP_Term_Query $query The WP_Term_Query instance, passed by reference.
 *
 * @return array|null
 */
function wp_kama_terms_pre_query_filter( $terms, $query ){

	// filter...
	return $terms;
}
$terms(массив|null)
Return an array of term data to short-circuit WP's term query, or null to allow WP queries to run normally.
$query(WP_Term_Query)
The WP_Term_Query instance, passed by reference.

Список изменений

С версии 5.3.0 Введена.

Где вызывается хук

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

Где используется хук в WordPress

Использование не найдено.