split_the_query
Filter HookDescription
Filters whether to split the query. 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. }Hook Information
File Location |
wp-includes/class-wp-query.php
View on GitHub
|
Hook Type | Filter |
Line Number | 3395 |
Hook Parameters
Type | Name | Description |
---|---|---|
bool
|
$split_the_query
|
Whether or not to split the query. |
WP_Query
|
$query
|
The WP_Query instance. |
string
|
$old_request
|
The complete SQL query before filtering. |
string[]
|
$clauses
|
{ Associative array of the clauses for the query. |
Usage Examples
Basic Usage
<?php
// Hook into split_the_query
add_filter('split_the_query', 'my_custom_filter', 10, 4);
function my_custom_filter($split_the_query, $query, $old_request, $clauses) {
// Your custom filtering logic here
return $split_the_query;
}
Source Code Context
wp-includes/class-wp-query.php:3395
- How this hook is used in WordPress core
<?php
3390 * @type string $distinct The DISTINCT clause of the query.
3391 * @type string $fields The SELECT clause of the query.
3392 * @type string $limits The LIMIT clause of the query.
3393 * }
3394 */
3395 $split_the_query = apply_filters( 'split_the_query', $split_the_query, $this, $old_request, compact( $pieces ) );
3396
3397 if ( $split_the_query ) {
3398 // First get the IDs and then fill in the objects.
3399
3400 // Beginning of the string is on a new line to prevent leading whitespace. See https://core.trac.wordpress.org/ticket/56841.
PHP Documentation
<?php
/**
* Filters whether to split the query.
*
* 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.
*
* @since 3.4.0
* @since 6.6.0 Added the `$old_request` and `$clauses` parameters.
*
* @param bool $split_the_query Whether or not to split the query.
* @param WP_Query $query The WP_Query instance.
* @param string $old_request The complete SQL query before filtering.
* @param string[] $clauses {
* Associative array of the clauses for the query.
*
* @type string $where The WHERE clause of the query.
* @type string $groupby The GROUP BY clause of the query.
* @type string $join The JOIN clause of the query.
* @type string $orderby The ORDER BY clause of the query.
* @type string $distinct The DISTINCT clause of the query.
* @type string $fields The SELECT clause of the query.
* @type string $limits The LIMIT clause of the query.
* }
*/
Quick Info
- Hook Type: Filter
- Parameters: 4
- File: wp-includes/class-wp-query.php
Related Hooks
Related hooks will be displayed here in future updates.