Skip to content

Instantly share code, notes, and snippets.

@richtabor
Created June 5, 2014 22:00
Show Gist options
  • Save richtabor/30660dbb9ce06c139d96 to your computer and use it in GitHub Desktop.
Save richtabor/30660dbb9ce06c139d96 to your computer and use it in GitHub Desktop.
/*===================================================================*/
/* SEARCH FILTER
/*===================================================================*/
if ( !function_exists( 'bean_search_filter' ) )
{
function bean_search_filter($query)
{
if ( !$query->is_admin && $query->is_search)
{
//UNCOMMENT BELOW TO SEARCH FOR POSTS ONLY
//$query->set('post_type', 'post' );
//UNCOMMENT BELOW TO SEARCH FOR PORTFOLIO ONLY
//$query->set('post_type', 'portfolio' );
//UNCOMMENT BELOW TO SEARCH FOR PAGES ONLY
//$query->set('post_type', 'page' );
$query->set('post_type', array('page', 'post', 'portfolio') );
}
return $query;
}
add_filter( 'pre_get_posts', 'bean_search_filter' );
} //END if ( !function_exists( 'bean_search_filter' ) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment