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


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

Available since: 1.0.8


View Parameters »

By default SearchWP returns an array of WordPress Post objects when performing searches. If you’re extending SearchWP and only want the IDs you can use this filter.

Example: Use this filter to conditionally return Post IDs instead of Post objects based on the search arguments, add the following to your active theme’s functions.php:

function my_maybe_searchwp_load_posts( $loadPosts, $args ) {
// print_r( $args ); // uncomment this line to see the engine arguments
return false; // return only post IDs
add_filter( 'searchwp_load_posts', 'my_maybe_searchwp_load_posts', 10, 2 );
view raw gistfile1.php hosted with ❤ by GitHub


Parameter Type Description
$loadPosts Boolean

Whether to load Post objects

$args Array

Array of arguments to be passed to the search algorithm

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