TIA
add_filter('pre_get_posts','SearchFilter');
function SearchFilter($query) {
if( ! is_admin() ) {
if ($query->is_search) {
$aPT = array();
if ( isset($_GET['include_docs']) )
$aPT[] = 'docs';
if ( isset($_GET['include_general']) ) {
$aPT[] = 'post';
$aPT[] = 'page';
}
if ( isset($_GET['include_nl']) )
$aPT[] = 'newsletter';
$query->set('post_type', $aPT );
$post_type = get_query_var('post_type');
if($post_type)
$post_type = $post_type;
else
$post_type = $aPT;
$query->set( 'cat', '-7,-19' ) // should only apply to posts not cpts
}
}
return $query;
add_filter('pre_get_posts','SearchFilter');
function SearchFilter($query) {
if( ! is_admin() ) {
if ($query->is_search) {
$aPT = array();
if ( isset($_GET['include_docs']) )
$aPT[] = 'docs';
if ( isset($_GET['include_general']) ) {
$aPT[] = 'post';
$aPT[] = 'page';
}
if ( isset($_GET['include_nl']) )
$aPT[] = 'newsletter';
$query->set('post_type', $aPT );
$post_type = get_query_var('post_type');
if($post_type)
$post_type = $post_type;
else
$post_type = $aPT;
$query->set( 'cat', '-7,-19' ) // should only apply to posts not cpts
}
}
return $query;