get_terms_fields filter-hookWP 2.8.0

Filters the fields to select in the terms query.

Field lists modified using this filter will only modify the term fields returned by the function when the $fields parameter set to 'count' or 'all'. In all other cases, the term fields in the results array will be determined by the $fields parameter alone.

Use of this filter can result in unpredictable behavior, and is not recommended.

Usage

add_filter( 'get_terms_fields', 'wp_kama_get_terms_fields_filter', 10, 3 );

/**
 * Function for `get_terms_fields` filter-hook.
 * 
 * @param string[] $selects    An array of fields to select for the terms query.
 * @param array    $args       An array of term query arguments.
 * @param string[] $taxonomies An array of taxonomy names.
 *
 * @return string[]
 */
function wp_kama_get_terms_fields_filter( $selects, $args, $taxonomies ){

	// filter...
	return $selects;
}
$selects(string[])
An array of fields to select for the terms query.
$args(array)
An array of term query arguments.
$taxonomies(string[])
An array of taxonomy names.

Changelog

Since 2.8.0 Introduced.

Where the hook is called

WP_Term_Query::get_terms()
get_terms_fields
wp-includes/class-wp-term-query.php 702
$fields = implode( ', ', apply_filters( 'get_terms_fields', $selects, $args, $taxonomies ) );

Where the hook is used in WordPress

Usage not found.