Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
function searchwp_include_only_tax_term( $ids, $engine, $terms ) {
// if mycat is the GET variable in use, we want to limit to a specific custom taxonomy term
if( isset( $_GET['mycat'] ) ) {
$my_taxonomy = 'my_taxonomy'; // taxonomy name
$my_term = absint( $_GET['mycat'] ); // taxonomy term as defined by form submission
$args = array( $my_taxonomy => $my_term, 'fields' => 'ids' );
$ids = get_posts( $args );
return $ids;
add_filter( 'searchwp_include', 'searchwp_include_only_tax_term', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.