WordPress.org

Make WordPress Core

Opened 19 months ago

Closed 8 months ago

#22001 closed defect (bug) (maybelater)

Handling private and protected posts when querying multiple post types

Reported by: tamlyn 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)

private_and_protected_posts.patch (1.5 KB) - added by tamlyn 19 months ago.

Download all attachments as: .zip

Change History (5)

comment:1 tamlyn19 months ago

  • Cc tamlyn@… added

comment:2 nacin19 months ago

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.

comment:3 SergeyBiryukov19 months ago

  • Version changed from trunk to 3.4

comment:4 wonderboymusic8 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from new to closed

No traction in a year.

Note: See TracTickets for help on using tickets.