WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 6 years ago

#6551 closed defect (bug) (fixed)

get_adjacent_post doesn't exclude categories

Reported by: filosofo Owned by:
Milestone: 2.5.1 Priority: normal
Severity: normal Version: 2.5
Component: Template Keywords: needs-patch 2nd-opinion
Focuses: Cc:

Description

So get_previous_post and get_next_post both can't exclude categories.

It would be great to get this into the 2.5 branch, since it's such a simple fix.

Attachments (1)

fix_get_adjacent_post.diff (518 bytes) - added by filosofo 7 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 @lloydbudd7 years ago

#4304 marked a dup of this.

comment:2 @ryan7 years ago

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

(In [7667]) Fix category exclusion when getting adjacent posts. Props filosofo. fixes #6551 for trunk

comment:3 @ryan7 years ago

(In [7668]) Fix category exclusion when getting adjacent posts. Props filosofo. fixes #6551 for 2.5

comment:4 @ryan7 years ago

  • Milestone changed from 2.6 to 2.5.1

comment:5 @TylerMartin7 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

The fix doesn't completely fix the problem. Even with the fix in place, if the post in the excluded category is also in any other category, the fact that it is in the excluded category is ignored and the post is not excluded from navigation (which is not the behavior of previous WordPress versions).

comment:6 @ryan7 years ago

  • Milestone changed from 2.5.2 to 2.9

Milestone 2.5.2 deleted

comment:7 @scribu7 years ago

  • Milestone changed from 2.9 to 2.6.1

I think this error might be related:

[30-Jul-2008 01:18:56] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') WHERE p.post_date > '2007-05-24 17:38:40' AND p.post_type = 'post' AND p.post_' at line 1 for query SELECT p.* FROM blog_posts AS p  INNER JOIN blog_term_relationships AS tr ON p.ID = tr.object_id INNER JOIN blog_term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id AND tt.taxonomy = 'category' AND tt.term_id IN () WHERE p.post_date > '2007-05-24 17:38:40' AND p.post_type = 'post' AND p.post_status = 'publish' AND tt.taxonomy = 'category' ORDER BY p.post_date ASC LIMIT 1 made by get_adjacent_post

comment:8 @westi7 years ago

  • Milestone changed from 2.6.1 to 2.6.2

2.6.1 has been released, moving to 2.6.2 milestone

comment:9 @matt7 years ago

  • Keywords has-patch removed
  • Milestone changed from 2.7 to 2.8

No patch for current problem, moving to 2.8.

comment:10 @Denis-de-Bernardy6 years ago

  • Milestone changed from 2.8 to Future Release

db error described by scribu no longer should occur in trunk based on what I'm reading.

whether the behavior described by TylerMartin is correct is debatable.

comment:11 @Denis-de-Bernardy6 years ago

  • Keywords needs-patch 2nd-opinion added; get_adjacent_post get_previous_post get_next_post removed

comment:12 @Denis-de-Bernardy6 years ago

  • Component changed from General to Template

comment:13 @Denis-de-Bernardy6 years ago

  • Milestone changed from Future Release to 2.5.1
  • Resolution set to fixed
  • Status changed from reopened to closed
  • Version changed from 2.6 to 2.5
Note: See TracTickets for help on using tickets.