mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
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:
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user