WordPress.org

Make WordPress Core

Ticket #22360: 22360.patch

File 22360.patch, 936 bytes (added by SergeyBiryukov, 3 years ago)
  • wp-includes/link-template.php

     
    11321132        if ( $in_same_cat || ! empty( $excluded_categories ) ) { 
    11331133                $join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id"; 
    11341134 
    1135                 if ( $in_same_cat ) { 
     1135                if ( $in_same_cat && is_object_in_taxonomy( $post->post_type, 'category' ) ) { 
    11361136                        $cat_array = wp_get_object_terms($post->ID, 'category', array('fields' => 'ids')); 
    1137                         $join .= " AND tt.taxonomy = 'category' AND tt.term_id IN (" . implode(',', $cat_array) . ")"; 
     1137                        if ( $cat_array ) 
     1138                                $join .= " AND tt.taxonomy = 'category' AND tt.term_id IN (" . implode(',', $cat_array) . ")"; 
    11381139                } 
    11391140 
    11401141                $posts_in_ex_cats_sql = "AND tt.taxonomy = 'category'";