[wp-trac] [WordPress Trac] #29050: wp_adjacent_posts excluded terms not returning proper relation

WordPress Trac noreply at wordpress.org
Tue Jul 29 01:08:05 UTC 2014


#29050: wp_adjacent_posts excluded terms not returning proper relation
--------------------------+-----------------------------
 Reporter:  crantron      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Query         |    Version:  3.9.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 When excluding a category(term_id) from this function it still will bring
 up posts with this excluded category if the post has more than one
 category assigned to it. Thus adding a sub select in the where clause
 which checks if all the categories(term_id's) are not in the excluded term
 list. (This is my first Trac submission so excuse me...)

 The following is the new code that I replaced on line 1465 of link-
 template.php

 {{{
 if ( ! empty( $excluded_terms ) ) {
                 $posts_in_ex_terms_sql = $wpdb->prepare( "
                                                         AND (
                                                             SELECT
 tt_ex.term_taxonomy_id
                                                             FROM
 wp_term_relationships       AS tr_ex
                                                                 INNER JOIN
 wp_term_taxonomy AS tt_ex ON tr_ex.term_taxonomy_id =
 tt_ex.term_taxonomy_id
                                                             WHERE
                                                                 p.ID =
 tr_ex.object_id
                                                                 AND
 tt_ex.term_taxonomy_id = tr_ex.term_taxonomy_id
                                                                 AND
 tt_ex.taxonomy = %s
                                                                 AND
 tt_ex.term_id IN (" . implode( $excluded_terms, ',' ) .')

                                                             ) IS NULL '
                                             , $taxonomy );
             }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29050>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list