| | 181 | function test_post_name__in_ordering() { |
| | 182 | $post_id1 = self::factory()->post->create( array( 'post_name' => 'id-1', 'post_type' => 'page' ) ); |
| | 183 | $post_id2 = self::factory()->post->create( array( 'post_name' => 'id-2', 'post_type' => 'page' ) ); |
| | 184 | $post_id3 = self::factory()->post->create( array( |
| | 185 | 'post_name' => 'id-3', |
| | 186 | 'post_type' => 'page', |
| | 187 | 'post_parent' => $post_id2 |
| | 188 | ) ); |
| | 189 | $post_id4 = self::factory()->post->create( array( |
| | 190 | 'post_name' => 'id-4', |
| | 191 | 'post_type' => 'page', |
| | 192 | 'post_parent' => $post_id2 |
| | 193 | ) ); |
| | 194 | $post_id5 = self::factory()->post->create( array( 'post_name' => 'id-5', 'post_type' => 'page' ) ); |
| | 195 | |
| | 196 | $ordered = array( 'id-2', 'id-4', 'id-3', 'id-1', 'id-5' ); |
| | 197 | |
| | 198 | $q = new WP_Query( array( |
| | 199 | 'post_type' => 'any', |
| | 200 | 'post_name__in' => $ordered, |
| | 201 | 'orderby' => 'post_name__in' |
| | 202 | ) ); |
| | 203 | |
| | 204 | $this->assertEquals( $ordered, wp_list_pluck( $q->posts, 'post_name' ) ); |
| | 205 | } |
| | 206 | |