Query: Allow results to be ordered by post_parent__in.

Props postpostmodern.
Fixes #36515.

git-svn-id: https://develop.svn.wordpress.org/trunk@37225 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2016-04-17 03:16:36 +00:00
parent d73ec171c0
commit 8ee26e699f
2 changed files with 30 additions and 2 deletions
+23
View File
@@ -178,6 +178,29 @@ class Tests_Post_Query extends WP_UnitTestCase {
$this->assertEqualSets( $ordered, wp_list_pluck( $attached->posts, 'ID' ) );
}
/**
* @ticket 36515
*/
public function test_post_name__in_ordering() {
$post_id1 = self::factory()->post->create( array( 'post_name' => 'id-1', 'post_type' => 'page' ) );
$post_id2 = self::factory()->post->create( array( 'post_name' => 'id-2', 'post_type' => 'page' ) );
$post_id3 = self::factory()->post->create( array(
'post_name' => 'id-3',
'post_type' => 'page',
'post_parent' => $post_id2
) );
$ordered = array( 'id-2', 'id-3', 'id-1' );
$q = new WP_Query( array(
'post_type' => 'any',
'post_name__in' => $ordered,
'orderby' => 'post_name__in'
) );
$this->assertSame( $ordered, wp_list_pluck( $q->posts, 'post_name' ) );
}
function test_post_status() {
$statuses1 = get_post_stati();
$this->assertContains( 'auto-draft', $statuses1 );