Opened 9 years ago
Last modified 5 years ago
#35761 new enhancement
Add filter(s) to get_adjacent_post function to change variables further down
Reported by: | briandichiara | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Query | Keywords: | needs-patch |
Focuses: | Cc: |
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
@
9 years ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to 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
,$where
and$sort
are used in the query string, these variables should probably passed to the filter callback as well.
patch to link-template.php to add 2 new filters