| | 60 | |
| | 61 | /** |
| | 62 | * @ticket 24785 |
| | 63 | * |
| | 64 | */ |
| | 65 | function test_nested_loop_reset_postdata() { |
| | 66 | $post_id = $this->factory->post->create(); |
| | 67 | $nested_post_id = $this->factory->post->create(); |
| | 68 | |
| | 69 | $first_query = new WP_Query( array( 'post__in' => array( $post_id ) ) ); |
| | 70 | while ( $first_query->have_posts() ) { $first_query->the_post(); |
| | 71 | $second_query = new WP_Query( array( 'post__in' => array( $nested_post_id ) ) ); |
| | 72 | while ( $second_query->have_posts() ) { |
| | 73 | $second_query->the_post(); |
| | 74 | $this->assertEquals( get_the_ID(), $nested_post_id ); |
| | 75 | } |
| | 76 | $first_query->reset_postdata(); |
| | 77 | $this->assertEquals( get_the_ID(), $post_id ); |
| | 78 | } |
| | 79 | |
| | 80 | } |