posts_orderby

Filters the ORDER BY clause of the query.

Description

add_filter( 'posts_orderby', (callback) $array ); 

Parameters (1)

0. $array (callback) => array( $this, 'handle_orderby_for_page_handle' )
The array.

Usage

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

Defined (4)

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

/json-endpoints/class.wpcom-json-api-list-media-v1-1-endpoint.php  
  1. add_filter( 'posts_orderby', array( $this, 'handle_orderby_for_page_handle' ) ); 
  1. remove_filter( 'posts_orderby', array( $this, 'handle_orderby_for_page_handle' ) ); 
/json-endpoints/class.wpcom-json-api-list-posts-v1-1-endpoint.php  
  1. add_filter( 'posts_orderby', array( $this, 'handle_orderby_for_page_handle' ) ); 
  1. remove_filter( 'posts_orderby', array( $this, 'handle_orderby_for_page_handle' ) );