Ticket #14699: better-tax-sql.diff
| File better-tax-sql.diff, 1.2 KB (added by , 16 years ago) |
|---|
-
query.php
2047 2047 $children = get_term_children($term->term_id, $taxonomy); 2048 2048 $term_ids = array_merge($term_ids, $children); 2049 2049 } 2050 2051 $join .= " INNER JOIN $wpdb->term_relationships tax_tr ON ($wpdb->posts.ID = tax_tr.object_id) INNER JOIN $wpdb->term_taxonomy tax_tt ON (tax_tr.term_taxonomy_id = tax_tt.term_taxonomy_id) "; 2052 $whichcat .= " AND tax_tt.taxonomy = '$taxonomy' "; 2053 $in_cats = "'" . implode("', '", $term_ids) . "'"; 2054 $whichcat .= "AND tax_tt.term_id IN ($in_cats)"; 2055 $groupby = "{$wpdb->posts}.ID"; 2050 2056 } 2051 $post_ids = get_objects_in_term($term_ids, $taxonomy);2052 if ( !is_wp_error($post_ids) && !empty($post_ids) ) {2053 $whichcat .= " AND $wpdb->posts.ID IN (" . implode(', ', $post_ids) . ") ";2054 if ( empty($post_type) ) {2055 $post_type = 'any';2056 $post_status_join = true;2057 } elseif ( in_array('attachment', (array)$post_type) ) {2058 $post_status_join = true;2059 }2060 } else {2061 $whichcat = " AND 0 ";2062 }2063 2057 } 2064 2058 } 2065 2059 2060 2066 2061 // Author/user stuff 2067 2062 2068 2063 if ( empty($q['author']) || ($q['author'] == '0') ) {