Opened 11 years ago
Closed 11 years ago
#29050 closed defect (bug) (duplicate)
wp_adjacent_posts excluded terms not returning proper relation
| Reported by: |
|
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)
Change History (2)
Note: See
TracTickets for help on using
tickets.
The altered link-template.php file