mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@31321 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -298,4 +298,19 @@ class Tests_Query_PostStatus extends WP_UnitTestCase {
|
||||
|
||||
$this->assertEmpty( $q->posts );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 29167
|
||||
*/
|
||||
public function test_specific_post_should_be_returned_if_trash_is_one_of_the_requested_post_statuses() {
|
||||
$p1 = $this->factory->post->create( array( 'post_status' => 'trash' ) );
|
||||
$p2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
|
||||
|
||||
$q = new WP_Query( array(
|
||||
'p' => $p1,
|
||||
'post_status' => array( 'trash', 'publish' ),
|
||||
) );
|
||||
|
||||
$this->assertContains( $p1, wp_list_pluck( $q->posts, 'ID' ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user