Changeset 7520 for trunk/wp-includes/query.php
- Timestamp:
- 03/26/2008 06:37:19 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/query.php
r7511 r7520 681 681 if ( empty($qv['taxonomy']) || empty($qv['term']) ) { 682 682 $this->is_tax = false; 683 foreach ( $GLOBALS['wp_taxonomies'] as $t ) { 684 if ( isset($t->query_var) && '' != $qv[$t->query_var] ) { 685 $this->is_tax = true; 686 break; 687 } 688 } 683 689 } else { 684 690 $this->is_tax = true; … … 1147 1153 // Taxonomies 1148 1154 if ( $this->is_tax ) { 1149 $terms = get_terms($q['taxonomy'], array('slug'=>$q['term'])); 1150 foreach ( $terms as $term ) 1151 $term_ids[] = $term->term_id; 1152 $post_ids = get_objects_in_term($term_ids, $q['taxonomy']); 1153 1154 if ( count($post_ids) ) { 1155 $whichcat .= " AND $wpdb->posts.ID IN (" . implode(', ', $post_ids) . ") "; 1156 $post_type = 'any'; 1157 $q['post_status'] = 'publish'; 1158 $post_status_join = true; 1155 if ( '' != $q['taxonomy'] ) { 1156 $taxonomy = $q['taxonomy']; 1157 $tt[$taxonomy] = $q['term']; 1158 $terms = get_terms($q['taxonomy'], array('slug'=>$q['term'])); 1159 1159 } else { 1160 $whichcat = " AND 0 = 1"; 1160 foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy => $t ) { 1161 if ( isset($t->query_var) && '' != $q[$t->query_var] ) { 1162 $terms = get_terms($taxonomy, array('slug'=>$q[$t->query_var])); 1163 if ( !is_wp_error($terms) ) 1164 break; 1165 } 1166 } 1167 } 1168 if ( is_wp_error($terms) || empty($terms) ) { 1169 $whichcat = " AND 0 "; 1170 } else { 1171 foreach ( $terms as $term ) 1172 $term_ids[] = $term->term_id; 1173 $post_ids = get_objects_in_term($term_ids, $taxonomy); 1174 if ( !is_wp_error($post_ids) && count($post_ids) ) { 1175 $whichcat .= " AND $wpdb->posts.ID IN (" . implode(', ', $post_ids) . ") "; 1176 $post_type = 'any'; 1177 $q['post_status'] = 'publish'; 1178 $post_status_join = true; 1179 } else { 1180 $whichcat = " AND 0 "; 1181 } 1161 1182 } 1162 1183 } … … 1297 1318 } 1298 1319 if ( $post_status_join ) { 1299 $join .= " INNERJOIN $wpdb->posts AS p2 ON ($wpdb->posts.post_parent = p2.ID) ";1320 $join .= " LEFT JOIN $wpdb->posts AS p2 ON ($wpdb->posts.post_parent = p2.ID) "; 1300 1321 foreach ( $statuswheres as $index => $statuswhere ) 1301 1322 $statuswheres[$index] = "($statuswhere OR ($wpdb->posts.post_status = 'inherit' AND " . str_replace($wpdb->posts, 'p2', $statuswhere) . "))";
Note: See TracChangeset
for help on using the changeset viewer.