Make WordPress Core

Opened 19 years ago

Closed 19 years ago

#2187 closed defect (bug) (fixed)

previous_post_link and next_post_link do not exclude specified category.

Reported by: berko's profile berko Owned by:
Milestone: Priority: high
Severity: normal Version: 2.0
Component: Template Keywords:
Focuses: Cc:

Description

Category passed to previous_post_link and next_post_link is not actually excluded.

Change History (4)

#1 @davidhouse
19 years ago

  • Resolution set to invalid
  • Status changed from new to closed

Huh? Looking at the code for previous_post_link (next_... is similar):

function previous_posts_link($label='« Previous Page') {
	global $paged;
	if ( (!is_single())	&& ($paged > 1) ) {
		echo '<a href="';
		previous_posts();
		echo '">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label) .'</a>';
	}
}

There's no mention of category exclusion anywhere. Invalid, reopen if you can explain yourself :)

#2 @berko
19 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

In template-functions-links.php find this code:

function previous_post_link($format='&laquo; %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {

When one specifies an excluded category, the category is not actually excluded from the navigation. Here is my template code. Category 2 is not excluded from my previous/next post navigation in single post view.

<div class="navigation">
	<div class="alignleft"><?php previous_post_link('&laquo; %link', '%title', false, '2') ?></div>
	<div class="alignright"><?php next_post_link('%link &raquo;', '%title', false, '2') ?></div>
</div>

#3 @berko
19 years ago

  • Priority changed from normal to high

#4 @matt
19 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [3508]) Exclude cats like we said we would, davidhouse. Fixes #2215 and fixes #2187

Note: See TracTickets for help on using tickets.