Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#29050 closed defect (bug) (duplicate)

wp_adjacent_posts excluded terms not returning proper relation

Reported by: crantron's profile crantron Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.9.1
Component: Query Keywords:
Focuses: Cc:

Description

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 );
            }

Attachments (1)

link-template.php (93.3 KB) - added by crantron 10 years ago.
The altered link-template.php file

Download all attachments as: .zip

Change History (2)

@crantron
10 years ago

The altered link-template.php file

#1 @SergeyBiryukov
10 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #22112.

Note: See TracTickets for help on using tickets.