Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Include only Posts and Pages in Search - Used with The Events Calendar 5.0 New Designs are Active
/**
* Include only Posts and Pages in Search
* Used with The Events Calendar 5.0 New Designs are Active
*
* @param $query WP_Query
*
* @return mixed
*/
function exclude_from_search($query) {
if ($query->is_search && empty( $query->query['tribe_suppress_query_filters'] ) ) {
$query->set('post_type', array( 'post', 'page' ) );
}
return $query;
}
add_filter('pre_get_posts','exclude_from_search');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment