Related Articles

For a business directory WordPress website with custom post types we’re developing at the moment, we only wanted to perform a site Search in the custom posts (the business directory). We didn’t want to display pages or regular blog posts and the search results page.

That’s very easy to do.

We simply modified the main query itself by using the pre_get_posts action.
In the functions.php file we added the following code: