Ticket #2415 (closed enhancement: fixed)

Opened 3 years ago

Last modified 2 years ago

New hooks for previous and next post

Reported by: majelbstoat Assigned to: majelbstoat
Priority: normal Milestone: 2.1
Component: Administration Version: 2.0.1
Severity: normal Keywords: hook previous next posts has-patch
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

prev_next_post hooks.diff (2.1 kB) - added by majelbstoat on 02/09/06 10:52:42.
Adds hooks to get_previous_post and get_next_post.
2415.diff (2.0 kB) - added by mdawaffe on 01/10/07 01:45:38.
why not go nuts?
2415b.diff (1.9 kB) - added by mdawaffe on 01/11/07 04:21:51.

Change History

02/09/06 10:52:42 changed by majelbstoat

  • attachment prev_next_post hooks.diff added.

Adds hooks to get_previous_post and get_next_post.

04/22/06 08:07:20 changed by majelbstoat

Any word on this?

09/09/06 07:53:04 changed by thanatos0

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

10/11/06 08:08:27 changed by hgurol

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...

10/11/06 08:17:24 changed by JeremyVisser

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.

(follow-up: ↓ 6 ) 10/11/06 08:37:25 changed by majelbstoat

  • 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.

(in reply to: ↑ 5 ) 10/11/06 12:58:24 changed by westi

  • 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

11/30/06 00:27:51 changed by matt

  • milestone changed from 2.1 to 2.2.

11/30/06 02:40:40 changed by majelbstoat

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

12/01/06 20:27:31 changed by hgurol

Can we have this with 2.1 please?

01/09/07 08:55:44 changed by fil

  • 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.

01/09/07 08:57:52 changed by fil

  • type changed from enhancement to defect.

01/09/07 22:37:31 changed by Nazgul

  • keywords changed from hook previous next posts bg|has-patch to hook previous next posts has-patch.
  • 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.

01/10/07 00:48:29 changed by ryan

Anyone want to update the patch for 2.1?

01/10/07 01:45:38 changed by mdawaffe

  • attachment 2415.diff added.

why not go nuts?

01/10/07 01:46:11 changed by mdawaffe

Updated and made ridiculous.

01/11/07 04:21:51 changed by mdawaffe

  • attachment 2415b.diff added.

01/11/07 04:30:46 changed by ryan

  • status changed from new to closed.
  • resolution set to fixed.

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