posts_where

Filters the WHERE clause of the query.

Description

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

Parameters (1)

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

Usage

To run the hook, copy the example below.
  1. $array = apply_filters( 'posts_where', $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_where callback 
  2. function filter_posts_where( $array ) { 
  3. // make filter magic happen here... 
  4. return $array
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'posts_where', 'filter_posts_where', 10, 1 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'posts_where', 'filter_posts_where', 10, 1 ); 

Defined (14)

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_where', array( $this, 'handle_where_for_page_handle' ) ); 
  1. add_filter( 'posts_where', array( $this, 'handle_date_range' ) ); 
  1. remove_filter( 'posts_where', array( $this, 'handle_date_range' ) ); 
  1. remove_filter( 'posts_where', array( $this, 'handle_where_for_page_handle' ) ); 
/json-endpoints/class.wpcom-json-api-list-posts-endpoint.php  
  1. add_filter( 'posts_where', array( $this, 'handle_date_range' ) ); 
  1. remove_filter( 'posts_where', array( $this, 'handle_date_range' ) ); 
/json-endpoints/class.wpcom-json-api-list-posts-v1-1-endpoint.php  
  1. add_filter( 'posts_where', array( $this, 'handle_date_range' ) ); 
  1. add_filter( 'posts_where', array( $this, 'handle_modified_range' ) ); 
  1. add_filter( 'posts_where', array( $this, 'handle_where_for_page_handle' ) ); 
  1. remove_filter( 'posts_where', array( $this, 'handle_date_range' ) ); 
  1. remove_filter( 'posts_where', array( $this, 'handle_modified_range' ) ); 
  1. remove_filter( 'posts_where', array( $this, 'handle_where_for_page_handle' ) ); 
/modules/infinite-scroll/infinity.php  
  1. add_filter( 'posts_where', array( $this, 'query_time_filter' ), 10, 2 ); 
  1. remove_filter( 'posts_where', array( $this, 'query_time_filter' ), 10, 2 );