Changeset 5592 for trunk/wp-includes/link-template.php
- Timestamp:
- 05/29/2007 04:52:31 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/link-template.php
r5590 r5592 360 360 $join = ''; 361 361 if ( $in_same_cat ) { 362 $join = " INNER JOIN $wpdb-> post2cat ON $wpdb->posts.ID= $wpdb->post2cat.post_id ";363 $cat_array = get_ the_category($post->ID);364 $join .= ' AND ( category_id = ' . intval($cat_array[0]->term_id);362 $join = " INNER JOIN $wpdb->term_relationships AS tr ON $wpdb->posts.ID = tr.object_id "; 363 $cat_array = get_object_terms($post->ID, 'category', 'fields=tt_ids'); 364 $join .= ' AND (tr.term_taxonomy_id = ' . intval($cat_array[0]); 365 365 for ( $i = 1; $i < (count($cat_array)); $i++ ) { 366 $join .= ' OR category_id = ' . intval($cat_array[$i]->term_id);366 $join .= ' OR tr.term_taxonomy_id = ' . intval($cat_array[$i]); 367 367 } 368 368 $join .= ')'; … … 372 372 if ( !empty($excluded_categories) ) { 373 373 $blah = explode(' and ', $excluded_categories); 374 foreach ( $blah as $category ) { 375 $category = intval($category); 376 $sql_cat_ids = " OR pc.category_ID = '$category'"; 377 } 378 $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"); 374 $posts_in_ex_cats = get_objects_in_term($blah, 'category'); 379 375 $posts_in_ex_cats_sql = 'AND ID NOT IN (' . implode($posts_in_ex_cats, ',') . ')'; 380 376 } … … 397 393 $join = ''; 398 394 if ( $in_same_cat ) { 399 $join = " INNER JOIN $wpdb-> post2cat ON $wpdb->posts.ID= $wpdb->post2cat.post_id ";400 $cat_array = get_ the_category($post->ID);401 $join .= ' AND ( category_id = ' . intval($cat_array[0]->term_id);395 $join = " INNER JOIN $wpdb->term_relationships AS tr ON $wpdb->posts.ID = tr.object_id "; 396 $cat_array = get_object_terms($post->ID, 'category', 'fields=tt_ids'); 397 $join .= ' AND (tr.term_taxonomy_id = ' . intval($cat_array[0]); 402 398 for ( $i = 1; $i < (count($cat_array)); $i++ ) { 403 $join .= ' OR category_id = ' . intval($cat_array[$i]->term_id);399 $join .= ' OR tr.term_taxonomy_id = ' . intval($cat_array[$i]); 404 400 } 405 401 $join .= ')'; … … 409 405 if ( !empty($excluded_categories) ) { 410 406 $blah = explode(' and ', $excluded_categories); 411 foreach ( $blah as $category ) { 412 $category = intval($category); 413 $sql_cat_ids = " OR pc.category_ID = '$category'"; 414 } 415 $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"); 407 $posts_in_ex_cats = get_objects_in_term($blah, 'category'); 416 408 $posts_in_ex_cats_sql = 'AND ID NOT IN (' . implode($posts_in_ex_cats, ',') . ')'; 417 409 }
Note: See TracChangeset
for help on using the changeset viewer.