Opened 13 years ago
Closed 12 years ago
#22001 closed defect (bug) (maybelater)
Handling private and protected posts when querying multiple post types
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.4 |
Component: | Query | Keywords: | has-patch |
Focuses: | Cc: |
Description
When querying multiple post types (e.g. new WP_Query(array('slug'=>$slug, 'post_type'=>'any') the automatic handling of protected and private posts fails because it looks for capabilities 'edit_any' and 'read_any' which don't exist.
The attached patch illustrates the problem with a suggested fix. However it's possible I have misunderstood how this is supposed to work.
Attachments (1)
Change History (5)
Note: See
TracTickets for help on using
tickets.
This is a known thing, really — It deliberately fails because it is not easy to construct sane SQL that will work individually across each post type + post_status pairing, as each post type is pretty much guaranteed to have different capabilities.
So essentially, you won't get back any private or protected posts unless you are querying a particular post type.
All ears on how to make this better.