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

---

# apply_filters_ref_array( ‘the_posts’, WP_Post[] $posts, WP_Query $query )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/the_posts/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/the_posts/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/the_posts/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/the_posts/?output_format=md#changelog)

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

Filters the array of retrieved posts after they’ve been fetched and internally processed.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/the_posts/?output_format=md#parameters)󠁿

 `$posts`[WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)[]

Array of post objects.

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

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

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

    ```php
    $this->posts = apply_filters_ref_array( 'the_posts', array( $this->posts, &$this ) );
    ```

[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#L3629)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-query.php#L3629-L3629)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/the_posts/?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/the_posts/?output_format=md#changelog)󠁿

| Version | Description | 
| [1.5.0](https://developer.wordpress.org/reference/since/1.5.0/) | Introduced. |

## User Contributed Notes

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