Exclude Post Types From Search

Sometimes I need / want to hide some post types from the built in WordPress search functionality. With a Custom Post Type this is really easy since you can just set the ‘exclude_from_search’ option when you register the post type.

However, some plugins register their own post types and sometimes we need to avoid searching these. Below is an example of excluding the Tribe Event Venues from search.

Thanks to oneTarek for the code.