get_terms_orderby

Filters the ORDERBY clause of the terms query.

Description

apply_filters( 'get_terms_orderby', (string) $orderby, (array) $this_query_vars, (array) $this_query_vars_taxonomy ); 

Parameters (3)

0. $orderby (string)
'ORDERBY' clause of the terms query.
1. $this_query_vars (array)
An array of terms query arguments.
2. $this_query_vars_taxonomy (array)
The this query vars taxonomy.

Usage

To run the hook, copy the example below.
  1. $orderby = apply_filters( 'get_terms_orderby', $orderby, $this_query_vars, $this_query_vars_taxonomy ); 
  2.  
  3. if ( !empty( $orderby ) ) { 
  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_orderby callback 
  2. function filter_get_terms_orderby( $orderby, $this_query_vars, $this_query_vars_taxonomy ) { 
  3. // make filter magic happen here... 
  4. return $orderby
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'get_terms_orderby', 'filter_get_terms_orderby', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'get_terms_orderby', 'filter_get_terms_orderby', 10, 3 ); 

Defined (1)

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

/wp-includes/class-wp-term-query.php  
  1. $orderby = apply_filters( 'get_terms_orderby', $orderby, $this->query_vars, $this->query_vars['taxonomy'] );