diff options
| author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-06-20 10:39:28 +0000 |
|---|---|---|
| committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-06-20 10:39:28 +0000 |
| commit | 4ebc9ae74b80b06ce5c5a215bb672b795642d56a (patch) | |
| tree | 7a4224f5f146f95032ca387ba949689fdf997db4 /wp-inst/wp-includes/query.php | |
| parent | d0d9e6ad956ddf6aa3fbeb247f1a1894973077d5 (diff) | |
| download | wordpress-mu-4ebc9ae74b80b06ce5c5a215bb672b795642d56a.tar.gz wordpress-mu-4ebc9ae74b80b06ce5c5a215bb672b795642d56a.tar.xz wordpress-mu-4ebc9ae74b80b06ce5c5a215bb672b795642d56a.zip | |
WP Merge
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@579 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-inst/wp-includes/query.php')
| -rw-r--r-- | wp-inst/wp-includes/query.php | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/wp-inst/wp-includes/query.php b/wp-inst/wp-includes/query.php index 034b271..0aca74b 100644 --- a/wp-inst/wp-includes/query.php +++ b/wp-inst/wp-includes/query.php @@ -708,7 +708,7 @@ class WP_Query { $q['cat'] = addslashes_gpc($q['cat']);
$join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) ";
$cat_array = preg_split('/[,\s]+/', $q['cat']);
- $in_cats = $out_cats = '';
+ $in_cats = $out_cats = $out_posts = '';
foreach ( $cat_array as $cat ) {
$cat = intval($cat);
$in = strstr($cat, '-') ? false : true;
@@ -722,8 +722,16 @@ class WP_Query { $out_cats = substr($out_cats, 0, -2);
if ( strlen($in_cats) > 0 )
$in_cats = " AND category_id IN ($in_cats)";
- if ( strlen($out_cats) > 0 )
- $out_cats = " AND category_id NOT IN ($out_cats)";
+ if ( strlen($out_cats) > 0 ) {
+ $ids = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id IN ($out_cats)");
+ if ( is_array($ids) && count($ids > 0) ) {
+ foreach ( $ids as $id )
+ $out_posts .= "$id, ";
+ $out_posts = substr($out_posts, 0, -2);
+ }
+ if ( strlen($out_posts) > 0 )
+ $out_cats = " AND ID NOT IN ($out_posts)";
+ }
$whichcat = $in_cats . $out_cats;
$distinct = 'DISTINCT';
}
|
