Opened 17 years ago
Closed 17 years ago
#10885 closed defect (bug) (fixed)
Custom post types show up in search
| Reported by: | ryan | Owned by: | ryan |
|---|---|---|---|
| Priority: | normal | Milestone: | 2.9 |
| Component: | Query | Version: | 2.8.4 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
Description (last modified by )
Custom post types can show up in search results. Searches set the post_type to "any". "any" queries pull in all post types except "revision", which is special cased. We need a means for plugins to exclude their type from searches. Either they can set a custom post_status to avoid getting in the search query as a matter of policy or provide API for registering the type and excluding it more formally.
Attachments (4)
Change History (14)
#3
@
17 years ago
Thinking we add register_post_type() and exclude all custom post types from search by default with ability to opt-in.
That sounds the best to me, Just have the initial list array('post', 'page', 'attachment') and let us filter it.. or.. Just let us filter the list which should be excluded..
#4
@
17 years ago
I considered simply adding an array of post types to exclude that can be filtered, but since other situations have come up where having a list of registered post types was needed I decide to go ahead and register them like we do with taxonomies.
#5
@
17 years ago
Sounds fair enough to me.
Could we add a few GET api's instead of using the globals directly? Much like the taxonomies..
get_post_types()
Could even simplify things a little for calling functions by doing an array_intersect, for example, This'd only return items matching...
get_post_types( array('exclude_from_search' => false) );
Would save other code blocks having to iterate over and check for conditionals themselves.. Just a thought :)
#7
@
17 years ago
Patch adds get_post_types(). Should it return a list of post type names or objects?
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Thinking we add register_post_type() and exclude all custom post types from search by default with ability to opt-in.