Ticket #4990: get_posts_cats.diff
File get_posts_cats.diff, 2.0 KB (added by , 18 years ago) |
---|
-
wp-includes/post.php
195 195 196 196 $defaults = array( 197 197 'numberposts' => 5, 'offset' => 0, 198 'category' => 0, 'orderby' => 'post_date',198 'category' => '', 'orderby' => 'post_date', 199 199 'order' => 'DESC', 'include' => '', 200 200 'exclude' => '', 'meta_key' => '', 201 201 'meta_value' =>'', 'post_type' => 'post', … … 207 207 208 208 $numberposts = (int) $numberposts; 209 209 $offset = (int) $offset; 210 $category = (int) $category;211 210 $post_parent = (int) $post_parent; 212 211 212 foreach( (array) preg_split('/[,\s]+/', $category) as $cat ) { 213 $cat = intval($cat); 214 $cat = abs($cat); 215 $cat_array[] = $cat; 216 } 217 $category = "'" . implode("', '", $cat_array) . "'"; 218 213 219 $inclusions = ''; 214 220 if ( !empty($include) ) { 215 221 $offset = 0; //ignore offset, category, exclude, meta_key, and meta_value, post_parent if using include … … 254 260 $query .= empty( $post_type ) ? '' : "AND post_type = '$post_type' "; 255 261 $query .= empty( $post_status ) ? '' : "AND post_status = '$post_status' "; 256 262 $query .= "$exclusions $inclusions " ; 257 $query .= empty( $category ) ? '' : "AND ($wpdb->posts.ID = $wpdb->term_relationships.object_id AND $wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id AND $wpdb->term_taxonomy.term_id = " . $category. ") ";263 $query .= empty( $category ) ? '' : "AND ($wpdb->posts.ID = $wpdb->term_relationships.object_id AND $wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id AND $wpdb->term_taxonomy.term_id IN ($category) ) "; 258 264 $query .= empty( $post_parent ) ? '' : "AND $wpdb->posts.post_parent = '$post_parent' "; 259 265 $query .= empty( $meta_key ) | empty($meta_value) ? '' : " AND ($wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '$meta_key' AND $wpdb->postmeta.meta_value = '$meta_value' )"; 260 266 $query .= " GROUP BY $wpdb->posts.ID ORDER BY " . $orderby . ' ' . $order;