Opened 6 years ago
Last modified 6 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: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
Hi
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.
Note: See
TracTickets for help on using
tickets.
You can already accomplish this using the pre_get_posts filter, reference here: https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts 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.