Note: You are viewing the documentation for Version 3View Version 4 Docs

Documentation

View the installation guide, browse the Knowledge Base, find out about SearchWP's many hooks, get support

Available since: 1.7.2

searchwp_found_post_objects

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:

<?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

Parameters

Parameter Type Description
$posts Array

Returned post objects

$args Array

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

Fix keyword search on your site. No coding required!

Now you can utilize all of the content that's gone unrecognized by native WordPress keyword search instantly with SearchWP

Get SearchWP