Make WordPress Core


Ignore:
Timestamp:
02/01/2015 08:25:42 PM (10 years ago)
Author:
boonebgorges
Message:

When querying for a specific post, allow posts with a non-public status to be returned as long as that status is specified.

This makes it possible to, for example, retrieve a specific post using the
p parameter of WP_Query, even if the post is in the Trash, by including
the post_status=trash parameter.

Props ebinnion.
Fixes #29167.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/query.php

    r31312 r31321  
    29642964        $user_id = get_current_user_id();
    29652965
     2966        $q_status = array();
    29662967        if ( ! empty( $q['post_status'] ) ) {
    29672968            $statuswheres = array();
     
    35283529            $post_status_obj = get_post_status_object($status);
    35293530            //$type = get_post_type($this->posts[0]);
    3530             if ( !$post_status_obj->public ) {
     3531
     3532            // If the post_status was specifically requested, let it pass through.
     3533            if ( !$post_status_obj->public && ! in_array( $status, $q_status ) ) {
     3534
    35313535                if ( ! is_user_logged_in() ) {
    35323536                    // User must be logged in to view unpublished posts.
Note: See TracChangeset for help on using the changeset viewer.