Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#18284 closed enhancement (worksforme)

Introduce 'post_status' => 'publish_or_private'

Reported by: scribu's profile scribu Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Query Keywords:
Focuses: Cc:


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)

#1 @nacin
12 years ago

array( 'publish', 'private' )?

#2 @scribu
12 years ago

Nope, that won't do because it doesn't check the appropriate user cap.

#3 @nacin
12 years ago

So you're looking for 'post_status' => array( 'publish', 'private' ), 'perm' => 'readable' then.

#4 @scribu
12 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.