From cbe5ebd66d8517e9a41e26691bfc0cd23e2d750e Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 21 May 2009 00:10:04 +0000 Subject: [PATCH] Revert [11392]. It breaks custom taxonomies for attachments. see #8731 git-svn-id: http://svn.automattic.com/wordpress/trunk@11420 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/query.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index f75e566573..60a08d67a6 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -1582,6 +1582,7 @@ class WP_Query { $search = ''; $groupby = ''; $fields = "$wpdb->posts.*"; + $post_status_join = false; $page = 1; if ( !isset($q['caller_get_posts']) ) @@ -1957,6 +1958,7 @@ class WP_Query { $whichcat .= " AND $wpdb->posts.ID IN (" . implode(', ', $post_ids) . ") "; $post_type = 'any'; $q['post_status'] = 'publish'; + $post_status_join = true; } else { $whichcat = " AND 0 "; } @@ -2111,6 +2113,11 @@ class WP_Query { else $statuswheres[] = "(" . join( ' OR ', $p_status ) . ")"; } + if ( $post_status_join ) { + $join .= " JOIN $wpdb->posts AS p2 ON ($wpdb->posts.post_parent = p2.ID) "; + foreach ( $statuswheres as $index => $statuswhere ) + $statuswheres[$index] = "($statuswhere OR ($wpdb->posts.post_status = 'inherit' AND " . str_replace($wpdb->posts, 'p2', $statuswhere) . "))"; + } foreach ( $statuswheres as $statuswhere ) $where .= " AND $statuswhere"; } elseif ( !$this->is_singular ) { @@ -2685,4 +2692,4 @@ function setup_postdata($post) { return true; } -?> \ No newline at end of file +?>