Manipulate what post statuses are included in the SearchWP index and for searches to a single supplemental search engine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
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