Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created March 2, 2014 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jchristopher/9311560 to your computer and use it in GitHub Desktop.
Save jchristopher/9311560 to your computer and use it in GitHub Desktop.
<?php
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