get_terms_fields

Filters the fields to select in the terms query.

Description

apply_filters( 'get_terms_fields', (array) $selects, (array) $args, (array) $taxonomies ); 

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.

Parameters (3)

0. $selects (array)
An array of fields to select for the terms query.
1. $args (array)
An array of term query arguments.
2. $taxonomies (array)
An array of taxonomies.

Usage

To run the hook, copy the example below.
  1. $selects = apply_filters( 'get_terms_fields', $selects, $args, $taxonomies ); 
  2.  
  3. if ( !empty( $selects ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the get_terms_fields callback 
  2. function filter_get_terms_fields( $selects, $args, $taxonomies ) { 
  3. // make filter magic happen here... 
  4. return $selects
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'get_terms_fields', 'filter_get_terms_fields', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'get_terms_fields', 'filter_get_terms_fields', 10, 3 ); 

Defined (1)

The filter is defined in the following location(s).

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