Ticket #4304: category_exclusion_fix.patch
| File category_exclusion_fix.patch, 1.8 KB (added by , 19 years ago) |
|---|
-
link-template.php
286 286 $join .= ')'; 287 287 } 288 288 289 $ sql_exclude_cats= '';289 $posts_in_ex_cats_sql = ''; 290 290 if ( !empty($excluded_categories) ) { 291 $blah = explode(' and ', $excluded_categories); 292 foreach ( $blah as $category ) { 291 $excluded_category_list = explode(' and ', $excluded_categories); 292 $sql_cat_ids = ''; 293 foreach ( $excluded_category_list as $category ) { 293 294 $category = intval($category); 294 $sql_cat_ids = " OR pc.category_ID = '$category'"; 295 if ($category > 0) { 296 $sql_cat_ids .= " OR pc.category_ID = '$category'"; 297 } 295 298 } 296 299 $posts_in_ex_cats = $wpdb->get_col("SELECT p.ID FROM $wpdb->posts p LEFT JOIN $wpdb->post2cat pc ON pc.post_id=p.ID WHERE 1 = 0 $sql_cat_ids GROUP BY p.ID"); 297 300 $posts_in_ex_cats_sql = 'AND ID NOT IN (' . implode($posts_in_ex_cats, ',') . ')'; … … 323 326 $join .= ')'; 324 327 } 325 328 326 $ sql_exclude_cats= '';329 $posts_in_ex_cats_sql = ''; 327 330 if ( !empty($excluded_categories) ) { 328 $blah = explode(' and ', $excluded_categories); 329 foreach ( $blah as $category ) { 331 $excluded_category_list = explode(' and ', $excluded_categories); 332 $sql_cat_ids = ''; 333 foreach ( $excluded_category_list as $category ) { 330 334 $category = intval($category); 331 $sql_cat_ids = " OR pc.category_ID = '$category'"; 335 if ($category > 0) { 336 $sql_cat_ids .= " OR pc.category_ID = '$category'"; 337 } 332 338 } 333 339 $posts_in_ex_cats = $wpdb->get_col("SELECT p.ID from $wpdb->posts p LEFT JOIN $wpdb->post2cat pc ON pc.post_id = p.ID WHERE 1 = 0 $sql_cat_ids GROUP BY p.ID"); 334 340 $posts_in_ex_cats_sql = 'AND ID NOT IN (' . implode($posts_in_ex_cats, ',') . ')';