#10791 closed enhancement (fixed)
Allow specific post_types to be specified in query
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | low | Milestone: | 2.9 |
| Component: | Query | Version: | 2.8.4 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | prettyboymp |
Description
Right now, wp_query only accepts a single post_type or 'any'. It would be nice to be able to specify an array of post_types to use.
Attachments (2)
Change History (8)
prettyboymp — 4 years ago
comment:2
prettyboymp — 4 years ago
Good call with the sql. I've updated this in attachment:ticket:10791:multiple-post-types.patch.
By the way, is there anyway to delete an attachment in Trac. I forgot to check the replace file option when uploading a previous version, hence the multiple-post-types.2.patch.
- Keywords has-patch added
By the way, is there anyway to delete an attachment in Trac.
Yes, But only Trac Admins have that ability.
I forgot to check the replace file option when uploading a previous version
In general, On the WordPress trac its considered best to not replace a existing patch, to allow for those who have downloaded the patch already to see theres a new one there.
- Resolution set to fixed
- Status changed from new to closed

This would probably help when using custom post types too. Wouldn't the SQL be better using
elseif ( !empty( $post_type ) && is_array( $post_type ) ) { $where .= " AND $wpdb->posts.post_type IN ('" . join("','", $post_type) . "')"; }