WordPress.org

Make WordPress Core

Opened 19 months ago

Last modified 7 weeks ago

#22112 new defect (bug)

get_adjacent_post excluded_categories isn't excluded — at Initial Version

Reported by: PatNarciso Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.8.1
Component: Posts, Post Types Keywords: 2nd-opinion has-patch dev-feedback
Focuses: template Cc:

Description

The category I expect to be excluded in $excluded_categories, is not excluded.

With get_adjacent_post,
Assuming $in_same_cat = TRUE
and $excluded_categories = 'ID_OF_CATEGORY'

$cat_array gets built with the ID's of categories it should include. cool.

But, when $excluded_categories contains an ID that $cat_array contains, the ID is removed from the $excluded_categories by array_diff() (link-template.php:1155).

So: the category I expect to be excluded in $excluded_categories, is not excluded.

My resolution: I remove 1154-1157.
if ( ! empty( $cat_array ) ) {

$excluded_categories = array_diff($excluded_categories, $cat_array);
$posts_in_ex_cats_sql = ;

}

Change History (0)

Note: See TracTickets for help on using tickets.