Make WordPress Core

Opened 5 years ago

Last modified 5 years ago

#46394 new feature request

Create a Function to Allow the WordPress Search to Only Return Results from a Specified Post Type

Reported by: pauljohnknight's profile pauljohnknight Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:



I'd like to install the WP search box on a custom post type archive page and have it only return results from this custom post type.

Is there any way in the future WordPress could allow you to add a parameter to the get_search_form() function (or create a similar function) that would allow this?

An example being, if I had a custom post type called jobs, when I add the WP search box on the jobs archive page I could add 'jobs' as a parameter so it only returned matches from the jobs post type i.e. get_search_form('jobs')

This would be so awesome.

Change History (1)

#1 @elrae
5 years ago

You can already accomplish this using the pre_get_posts filter, reference here: for more information on how to put that together. Unless this doesn't cover your use-case for some reason, I doubt this will be something that gets implemented.

Note: See TracTickets for help on using tickets.