the_posts filter-hookWP 1.5.0

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

Usage

add_filter( 'the_posts', 'wp_kama_the_posts_filter', 10, 2 );

/**
 * Function for `the_posts` filter-hook.
 * 
 * @param WP_Post[] $posts Array of post objects.
 * @param WP_Query  $query The WP_Query instance (passed by reference).
 *
 * @return WP_Post[]
 */
function wp_kama_the_posts_filter( $posts, $query ){

	// filter...
	return $posts;
}
$posts(WP_Post[])
Array of post objects.
$query(WP_Query)
The WP_Query instance (passed by reference).

Changelog

Since 1.5.0 Introduced.

Where the hook is called

WP_Query::get_posts()
the_posts
wp-includes/class-wp-query.php 3321
$this->posts = apply_filters_ref_array( 'the_posts', array( $this->posts, &$this ) );

Where the hook is used in WordPress

wp-includes/default-filters.php 296
add_filter( 'the_posts', '_close_comments_for_old_posts', 10, 2 );