Created
November 8, 2019 00:14
-
-
Save chrispian/8a3aa0ab2c0a12ecea285bd0bfc4769d to your computer and use it in GitHub Desktop.
Limit WP Search to certain post types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function filter_search($query) { | |
if ($query->is_search) { | |
$query->set('post_type', array('post', 'tribe_events', 'page')); | |
}; | |
return $query; | |
}; | |
add_filter('pre_get_posts', 'filter_search'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment