Title: split_the_query
Published: April 25, 2014
Last modified: February 24, 2026

---

# apply_filters( ‘split_the_query’, bool $split_the_query, WP_Query $query, string $old_request, string[] $clauses )

## In this article

 * [Description](https://developer.wordpress.org/reference/hooks/split_the_query/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/hooks/split_the_query/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/split_the_query/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/split_the_query/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/split_the_query/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/split_the_query/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/hooks/split_the_query/?output_format=md#wp--skip-link--target)

Filters whether to split the query.

## 󠀁[Description](https://developer.wordpress.org/reference/hooks/split_the_query/?output_format=md#description)󠁿

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](https://developer.wordpress.org/reference/hooks/split_the_query/?output_format=md#parameters)󠁿

 `$split_the_query`bool

Whether or not to split the query.

`$query`[WP_Query](https://developer.wordpress.org/reference/classes/wp_query/)

The [WP_Query](https://developer.wordpress.org/reference/classes/wp_query/) instance.

`$old_request`string

The complete SQL query before filtering.

`$clauses`string[]

Associative array of the clauses for the query.

 * `where` string
 * The WHERE clause of the query.
 * `groupby` string
 * The GROUP BY clause of the query.
 * `join` string
 * The JOIN clause of the query.
 * `orderby` string
 * The ORDER BY clause of the query.
 * `distinct` string
 * The DISTINCT clause of the query.
 * `fields` string
 * The SELECT clause of the query.
 * `limits` string
 * The LIMIT clause of the query.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/split_the_query/?output_format=md#source)󠁿

    ```php
    $split_the_query = apply_filters( 'split_the_query', $split_the_query, $this, $old_request, compact( $pieces ) );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-query.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-query.php#L3404)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-query.php#L3404-L3404)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/split_the_query/?output_format=md#related)󠁿

| Used by | Description | 
| [WP_Query::get_posts()](https://developer.wordpress.org/reference/classes/wp_query/get_posts/)`wp-includes/class-wp-query.php` |

Retrieves an array of posts based on query variables.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/split_the_query/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.6.0](https://developer.wordpress.org/reference/since/6.6.0/) | Added the `$old_request` and `$clauses` parameters. | 
| [3.4.0](https://developer.wordpress.org/reference/since/3.4.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/split_the_query/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/hooks/split_the_query/?output_format=md#comment-content-6457)
 2.   [Till Krüss](https://profiles.wordpress.org/tillkruess/)  [  3 years ago  ](https://developer.wordpress.org/reference/hooks/split_the_query/#comment-6457)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fsplit_the_query%2F%23comment-6457)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fsplit_the_query%2F%23comment-6457)
 4. See [https://core.trac.wordpress.org/ticket/57296](https://core.trac.wordpress.org/ticket/57296)
    for possible use-case.
 5.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fsplit_the_query%2F%3Freplytocom%3D6457%23feedback-editor-6457)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fsplit_the_query%2F)
before being able to contribute a note or feedback.