Make WordPress Core


Ignore:
Timestamp:
11/08/2012 09:16:15 PM (12 years ago)
Author:
nacin
Message:

Return nothing in get_adjacent_post() when $in_same_cat = true but the post doesn't support (or otherwise have) categories. Avoids SQL error. props batmoo, SergeyBiryukov. fixes #15959.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/link-template.php

    r22431 r22472  
    11341134
    11351135        if ( $in_same_cat ) {
     1136            if ( ! is_object_in_taxonomy( $post->post_type, 'category' ) )
     1137                return '';
    11361138            $cat_array = wp_get_object_terms($post->ID, 'category', array('fields' => 'ids'));
     1139            if ( ! $cat_array || is_wp_error( $cat_array ) )
     1140                return '';
    11371141            $join .= " AND tt.taxonomy = 'category' AND tt.term_id IN (" . implode(',', $cat_array) . ")";
    11381142        }
Note: See TracChangeset for help on using the changeset viewer.