Ticket #4822: 4822.diff
| File 4822.diff, 3.6 KB (added by , 18 years ago) |
|---|
-
wp-includes/link-template.php
365 365 366 366 $join = ''; 367 367 if ( $in_same_cat ) { 368 $join = " INNER JOIN $wpdb->term_relationships AS tr ON $wpdb->posts.ID = tr.object_id ";368 $join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id "; 369 369 $cat_array = wp_get_object_terms($post->ID, 'category', 'fields=tt_ids'); 370 370 $join .= ' AND (tr.term_taxonomy_id = ' . intval($cat_array[0]); 371 371 for ( $i = 1; $i < (count($cat_array)); $i++ ) { … … 378 378 if ( !empty($excluded_categories) ) { 379 379 $blah = explode(' and ', $excluded_categories); 380 380 $posts_in_ex_cats = get_objects_in_term($blah, 'category'); 381 $posts_in_ex_cats_sql = 'AND ID NOT IN (' . implode($posts_in_ex_cats, ',') . ')';381 $posts_in_ex_cats_sql = 'AND p.ID NOT IN (' . implode($posts_in_ex_cats, ',') . ')'; 382 382 } 383 383 384 384 $join = apply_filters( 'get_previous_post_join', $join, $in_same_cat, $excluded_categories ); 385 $where = apply_filters( 'get_previous_post_where', "WHERE p ost_date < '$current_post_date' AND post_type = 'post' ANDpost_status = 'publish' $posts_in_ex_cats_sql", $in_same_cat, $excluded_categories );386 $sort = apply_filters( 'get_previous_post_sort', 'ORDER BY p ost_date DESC LIMIT 1' );385 $where = apply_filters( 'get_previous_post_where', "WHERE p.post_date < '$current_post_date' AND p.post_type = 'post' AND p.post_status = 'publish' $posts_in_ex_cats_sql", $in_same_cat, $excluded_categories ); 386 $sort = apply_filters( 'get_previous_post_sort', 'ORDER BY p.post_date DESC LIMIT 1' ); 387 387 388 return @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts$join $where $sort");388 return @$wpdb->get_row("SELECT p.ID, p.post_title FROM $wpdb->posts AS p $join $where $sort"); 389 389 } 390 390 391 391 function get_next_post($in_same_cat = false, $excluded_categories = '') { … … 398 398 399 399 $join = ''; 400 400 if ( $in_same_cat ) { 401 $join = " INNER JOIN $wpdb->term_relationships AS tr ON $wpdb->posts.ID = tr.object_id ";401 $join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id "; 402 402 $cat_array = wp_get_object_terms($post->ID, 'category', 'fields=tt_ids'); 403 403 $join .= ' AND (tr.term_taxonomy_id = ' . intval($cat_array[0]); 404 404 for ( $i = 1; $i < (count($cat_array)); $i++ ) { … … 411 411 if ( !empty($excluded_categories) ) { 412 412 $blah = explode(' and ', $excluded_categories); 413 413 $posts_in_ex_cats = get_objects_in_term($blah, 'category'); 414 $posts_in_ex_cats_sql = 'AND ID NOT IN (' . implode($posts_in_ex_cats, ',') . ')';414 $posts_in_ex_cats_sql = 'AND p.ID NOT IN (' . implode($posts_in_ex_cats, ',') . ')'; 415 415 } 416 416 417 417 $join = apply_filters( 'get_next_post_join', $join, $in_same_cat, $excluded_categories ); 418 $where = apply_filters( 'get_next_post_where', "WHERE p ost_date > '$current_post_date' AND post_type = 'post' AND post_status = 'publish' $posts_in_ex_cats_sql ANDID != $post->ID", $in_same_cat, $excluded_categories );419 $sort = apply_filters( 'get_next_post_sort', 'ORDER BY p ost_date ASC LIMIT 1' );418 $where = apply_filters( 'get_next_post_where', "WHERE p.post_date > '$current_post_date' AND p.post_type = 'post' AND p.post_status = 'publish' $posts_in_ex_cats_sql AND p.ID != $post->ID", $in_same_cat, $excluded_categories ); 419 $sort = apply_filters( 'get_next_post_sort', 'ORDER BY p.post_date ASC LIMIT 1' ); 420 420 421 return @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts$join $where $sort");421 return @$wpdb->get_row("SELECT p.ID, p.post_title FROM $wpdb->posts AS p $join $where $sort"); 422 422 } 423 423 424 424