Skip to content

Instantly share code, notes, and snippets.

@jesseeproductions
Created February 26, 2020 16:49
Show Gist options
  • Save jesseeproductions/cb21371f4921eb24ced1ea40ed35f058 to your computer and use it in GitHub Desktop.
Save jesseeproductions/cb21371f4921eb24ced1ea40ed35f058 to your computer and use it in GitHub Desktop.
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