Opened 12 years ago
Closed 12 years ago
#18284 closed enhancement (worksforme)
Introduce 'post_status' => 'publish_or_private'
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Query | Keywords: | |
Focuses: | Cc: |
Description
This code:
$query = new WP_Query(); print_r( $query->posts );
will contain private posts, if the user has the appropriate capabilities.
This code:
$posts = get_posts(); print_r( $posts );
won't contain private posts.
That's because get_posts() always sets 'post_status' to 'publish', for back-compat.
Therefore, I propose we introduce an explicit 'publish_or_private' value, which would allow this:
$posts = get_posts( array( 'post_status' => 'publish_or_private' ) );
Change History (4)
#3
@
12 years ago
So you're looking for 'post_status' => array( 'publish', 'private' ), 'perm' => 'readable'
then.
#4
@
12 years ago
- Milestone Awaiting Review deleted
- Resolution set to worksforme
- Status changed from new to closed
Fair enough. Added example to the Codex:
http://codex.wordpress.org/Class_Reference/WP_Query#Permission_Parameters
Note: See
TracTickets for help on using
tickets.
array( 'publish', 'private' )
?