WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 7 years ago

#2415 closed enhancement (fixed)

New hooks for previous and next post

Reported by: majelbstoat Owned by: majelbstoat
Milestone: 2.1 Priority: normal
Severity: normal Version: 2.0.1
Component: Administration Keywords: hook previous next posts has-patch
Focuses: Cc:

Description

Getting the previous and next posts can be filtered by excluding categories, but it would be better to be able to filter more flexibly, like you can for get_posts(). The attached patch adds two new hooks prev_next_post_join and prev_next_post_where which are identical in purpose to the posts_where and posts_join filters.

The specific case I want to solve in filtering based on a custom query variable.

Attachments (3)

prev_next_post hooks.diff (2.1 KB) - added by majelbstoat 8 years ago.
Adds hooks to get_previous_post and get_next_post.
2415.diff (2.0 KB) - added by mdawaffe 7 years ago.
why not go nuts?
2415b.diff (1.9 KB) - added by mdawaffe 7 years ago.

Download all attachments as: .zip

Change History (18)

majelbstoat8 years ago

Adds hooks to get_previous_post and get_next_post.

comment:1 majelbstoat8 years ago

Any word on this?

comment:2 thanatos08 years ago

Please integrate this into the next version. There's a huge multilingual community who would like support for it.

comment:3 hgurol8 years ago

Yes please, I also would like to see this one integrated into WP core. The lack of these hooks turns to be one of the major headaches for us, the multilingual blog owners.

Even better; move this one to 2.0.5 milestone if it can be included in 2.0.5's own scope.

thanks...

comment:4 JeremyVisser8 years ago

Personally, I would feel wary of adding new hooks to a bugfix release, which is primarily what 2.0.5's purpose is. I think plugins should be able to be written for the 2.0 or 2.1 branch, rather than for a specific revision, such as 2.0.4 or 2.0.5.

I don't think it would be great to have a plugin that worked on 2.0.5 and not 2.0.4, unless the reason the plugin broke on 2.0.4 was because of a bug in the core.

comment:5 follow-up: majelbstoat8 years ago

  • Milestone changed from 2.1 to 2.0.5

You can write plugins in a way that handles all cases. If you write a plugin that registers a non-existant filter, nothing goes wrong. It just starts to work 'better' when the filter becomes available.

Adding a filter isn't dangerous at all. You could safely assume in 99% of cases (except here, where I raised the ticket myself) that nobody's using that filter - why would they when it doesn't exist? At the very worst, it is temporarily redundant, until plugins are written to take advantage of it. And here, not even this is the case.

Gengo, the plugin for which I found a need for this filter, has had code in place to take advantage of this hook for 8 months now. It still works without it, but the posts aren't filtered correctly. As soon as this is in the core, Gengo will filter the posts better, with no modifications.

I'd really like this in 2.0.5 too. Feel free to put it back to 2.1 if there's a compelling reason.

comment:6 in reply to: ↑ 5 westi8 years ago

  • Milestone changed from 2.0.5 to 2.1

Replying to majelbstoat:

You can write plugins in a way that handles all cases. If you write a plugin that registers a non-existant filter, nothing goes wrong. It just starts to work 'better' when the filter becomes available.

Agreed

Adding a filter isn't dangerous at all. You could safely assume in 99% of cases (except here, where I raised the ticket myself) that nobody's using that filter - why would they when it doesn't exist? At the very worst, it is temporarily redundant, until plugins are written to take advantage of it. And here, not even this is the case.

Agreed

I'd really like this in 2.0.5 too. Feel free to put it back to 2.1 if there's a compelling reason.

2.0.5 is a bug fix release - we should not be adding new features.

2.1 is not that far away therefore my vote for this is leave it for 2.1

comment:7 matt7 years ago

  • Milestone changed from 2.1 to 2.2

comment:8 majelbstoat7 years ago

Can I ask why such a minor but useful modification will not be present in the next major release?

comment:9 hgurol7 years ago

Can we have this with 2.1 please?

comment:10 fil7 years ago

  • Milestone changed from 2.2 to 2.1

Setting the milestone to 2.1 given the low-impact and available patch. This unblocks many plugins who restrict posts.

comment:11 fil7 years ago

  • Type changed from enhancement to defect

comment:12 Nazgul7 years ago

  • Keywords has-patch added; bg|has-patch removed
  • Type changed from defect to enhancement

This is an enhancement request, not a defect.

But we've been postponing this low-impact patch for some time now, so I don't see a reason we shouldn't finally include this in 2.1.

comment:13 ryan7 years ago

Anyone want to update the patch for 2.1?

mdawaffe7 years ago

why not go nuts?

comment:14 mdawaffe7 years ago

Updated and made ridiculous.

mdawaffe7 years ago

comment:15 ryan7 years ago

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

(In [4721]) Prev/next query filters. Props mdwaffe. fixes #2415

Note: See TracTickets for help on using tickets.