Is there an action/filter called when WP_Query->query is finished and assigns posts

I took a look at the WP_Query->get_posts() function and couldn’t see any action/filter that is called AFTER a query finishes.

I want to be able to manipulate the results once they are sent, rather than the query itself (Using a Human Name Parser to sort by last name).

I’m revamping an old site that alters the global $wp_query->posts right within archive.php, so I was just wondering if there was a way to take this logic completely out of the archive file and store it with my other CPT functionality.

Cheers!

1 Answer
1

The is the the_posts filter, which sounds like what you want.

function filter_the_posts($posts) {
  var_dump($posts);
}
add_filter('the_posts','filter_the_posts');

Leave a Comment