This Documentation is for SearchWP Version 3

Available since: 1.7.2


View Parameters »

If you would like to manipulate the post objects returned by a SearchWP query, you can use this hook to do so. Please note that this hook does not fire if you have prevented SearchWP from loading post objects.

To filter the array of post objects returned by a SearchWP query, add something like the following to your theme’s functions.php:

function my_searchwp_found_post_objects( $posts, $args ) {
// manipulate the $posts array in any way you'd like
return $posts;
add_filter( 'searchwp_found_post_objects', 'my_searchwp_found_post_objects', 10, 2 );
view raw gistfile1.php hosted with ❤ by GitHub


Parameter Type Description
$posts Array

Returned post objects

$args Array

Arguments passed to a call to get_posts() that generated the $posts argument