In a plugin, I have this simple code:
add_filter( 'the_posts', 'process_search_results', 10, 2 );
function process_search_results($posts, $query=false) {
print_r($posts);
}
This shows the list of posts that will be looped over in the loop. But on a search page, an empty array (Array()
) is printed, while the search results are still shown. Why is $posts
empty for searches?
Some background: I'll try to code a custom search plugin that should merge results from an external data source into the default results.