From 66e73d0f6401520e1b2adb4e6d44a35c4e943794 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Sat, 17 Apr 2010 09:03:33 +0000 Subject: [PATCH] Respect the post_type param for Taxonomy Queries, Props Otto & Dougal Campbell. Restrict Attachment post_status joins to queries involving attachment results ("any" or "attachment"). See #13020 git-svn-id: https://develop.svn.wordpress.org/trunk@14121 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/query.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index 6b42a5d346..f2616312a1 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -2031,9 +2031,13 @@ class WP_Query { $post_ids = get_objects_in_term($term_ids, $taxonomy); if ( !is_wp_error($post_ids) && !empty($post_ids) ) { $whichcat .= " AND $wpdb->posts.ID IN (" . implode(', ', $post_ids) . ") "; - $post_type = 'any'; + if ( '' === $post_type ) { + $post_type = 'any'; + $post_status_join = true; + } elseif ( in_array('attachment', (array)$post_type) ) { + $post_status_join = true; + } $q['post_status'] = 'publish'; - $post_status_join = true; } else { $whichcat = " AND 0 "; } @@ -2292,9 +2296,8 @@ class WP_Query { // Paging if ( empty($q['nopaging']) && !$this->is_singular ) { $page = absint($q['paged']); - if (empty($page)) { + if ( empty($page) ) $page = 1; - } if ( empty($q['offset']) ) { $pgstrt = '';