Changeset 3508
- Timestamp:
- 02/09/06 08:26:30 (3 years ago)
- Files:
-
- trunk/wp-includes/template-functions-links.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/wp-includes/template-functions-links.php
r3505 r3508 253 253 $sql_exclude_cats = ''; 254 254 if ( !empty($excluded_categories) ) { 255 $blah = explode(' and', $excluded_categories);255 $blah = explode(' and ', $excluded_categories); 256 256 foreach ( $blah as $category ) { 257 257 $category = intval($category); 258 $sql_exclude_cats .= " AND post_category != $category"; 259 } 260 } 261 262 return @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts $join WHERE post_date < '$current_post_date' AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT 1"); 258 $sql_cat_ids = " OR pc.category_ID = '$category'"; 259 } 260 $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"); 261 $posts_in_ex_cats_sql = 'AND ID NOT IN (' . implode($posts_in_ex_cats, ',') . ')'; 262 } 263 264 return @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts $join WHERE post_date < '$current_post_date' AND post_status = 'publish' $posts_in_ex_cats_sql ORDER BY post_date DESC LIMIT 1"); 263 265 } 264 266 … … 284 286 $sql_exclude_cats = ''; 285 287 if ( !empty($excluded_categories) ) { 286 $blah = explode(' and', $excluded_categories);288 $blah = explode(' and ', $excluded_categories); 287 289 foreach ( $blah as $category ) { 288 290 $category = intval($category); 289 $sql_exclude_cats .= " AND post_category != $category"; 290 } 291 $sql_cat_ids = " OR pc.category_ID = '$category'"; 292 } 293 $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"); 294 $posts_in_ex_cats_sql = 'AND ID NOT IN (' . implode($posts_in_ex_cats, ',') . ')'; 291 295 } 292 296 293 297 $now = current_time('mysql'); 294 298 295 return @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts $join WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_status = 'publish' $ sqlcat $sql_exclude_catsAND ID != $post->ID ORDER BY post_date ASC LIMIT 1");299 return @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts $join WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_status = 'publish' $posts_in_ex_cats_sql AND ID != $post->ID ORDER BY post_date ASC LIMIT 1"); 296 300 } 297 301
