Skip to content

Instantly share code, notes, and snippets.

Last active January 2, 2016 10:09
What would you like to do?
Manipulate what post statuses are included in the SearchWP index and for searches to a single supplemental search engine
function my_searchwp_post_statuses( $post_status, $engine ) {
$limited_post_status = array( 'publish' );
$additional_post_status = array( 'publish', 'private' );
if( is_null( $engine ) ) {
// this is the indexer running, so we want to index our additional content
$post_status = $additional_post_status;
} else {
// a search is taking place, but we only want to expose
// additional content if it's the my_supplemental_search search engine
if( 'my_supplemental_search' == $engine ) {
$post_status = $additional_post_status;
} else {
// this is a search that is NOT using the my_supplemental_search search engine
$post_status = $limited_post_status;
return $post_status;
add_filter( 'searchwp_post_statuses', 'my_searchwp_post_statuses', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment