diff --git src/wp-includes/query.php src/wp-includes/query.php
index 55f6172..9fe9fe6 100644
|
|
class WP_Query { |
3116 | 3116 | $where .= " AND ($where_status)"; |
3117 | 3117 | } |
3118 | 3118 | } elseif ( !$this->is_singular ) { |
3119 | | $where .= " AND ($wpdb->posts.post_status = 'publish'"; |
| 3119 | $where .= " AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'inherit'"; |
3120 | 3120 | |
3121 | 3121 | // Add public states. |
3122 | 3122 | $public_states = get_post_stati( array('public' => true) ); |
diff --git tests/phpunit/tests/query/search.php tests/phpunit/tests/query/search.php
index caf862c..4eaff9b 100644
|
|
class Tests_Query_Search extends WP_UnitTestCase { |
125 | 125 | |
126 | 126 | $this->assertEqualSets( array( $p3 ), $q->posts ); |
127 | 127 | } |
| 128 | |
| 129 | /** |
| 130 | * @ticket 27266 |
| 131 | */ |
| 132 | function test_search_attachments() { |
| 133 | $post = self::factory()->post->create( array( 'post_title' => 'Post 1', 'post_type' => 'post' ) ); |
| 134 | $page = self::factory()->post->create( array( 'post_title' => 'Post 2', 'post_type' => 'page' ) ); |
| 135 | $attachment = self::factory()->post->create( array( 'post_title' => 'Post 3', 'post_type' => 'attachment' ) ); |
| 136 | |
| 137 | $q = new WP_Query( array( |
| 138 | 's' => 'Post', |
| 139 | 'fields' => 'ids', |
| 140 | ) ); |
| 141 | |
| 142 | $this->assertEqualSets( array( $post, $page, $attachment ), $q->posts ); |
| 143 | } |
128 | 144 | } |