Opened 11 years ago
Last modified 7 years ago
#35761 new enhancement
Add filter(s) to get_adjacent_post function to change variables further down
| Reported by: | briandichiara | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Query | Version: | |
| Severity: | normal | Keywords: | needs-patch |
| Cc: | Focuses: |
Description
I'm finding it incredibly difficult to sort a post type using the existing filters to order by custom post meta alphabetically on a single post (for next/previous post).
A use case is when I have a separate field for a custom post type called "Last Name" where I would want my posts to display in alphabetical order by last name. When sorting on an archive with pre_get_posts, it's not a problem, however when navigating posts from the single post, there just doesn't appear to be a simple way to change the "next" and "previous" posts to maintain the same custom sort order when dealing with an alphabetical meta_value.
I'm proposing adding one or two filters to the get_adjacent_post() function which allows the final query to be filtered, or more importantly, the query result to be filtered so a custom sort can be implemented.
Attachments (2)
Change History (4)
#1
@
11 years ago
- Keywords needs-patch added
- Milestone Awaiting Review → Future Release
Hey Brian
The use case sounds reasonable. Two notes on the patch:
- The filters need appropriate documentation, see for more information
- Since
$join,$whereand$sortare used in the query string, these variables should probably passed to the filter callback as well.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
patch to link-template.php to add 2 new filters