split_the_query

Filters whether to split the query.

Description

apply_filters( 'split_the_query', (bool) $split_the_query, (WP_Query) $instance ); 

Splitting the query will cause it to fetch just the IDs of the found posts (and then individually fetch each post by ID), rather than fetching every complete row at once. One massive result vs. many small results.

Parameters (2)

0. $split_the_query (bool)
Whether or not to split the query.
1. $instance (WP_Query)
The WP_Query instance.

Usage

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

Defined (1)

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

/wp-includes/class-wp-query.php  
  1. $split_the_query = apply_filters( 'split_the_query', $split_the_query, $this );