[4.x] Fix entries on the same date being ignored by collection previous/next tags #8921
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request fixes an issue where the
{{ collection:previous }}
and{{ collection:next }}
tags would ignore other entries published on the same date.For example, say you had the following entries:
When you visited the "Article C" entry, the
{{ collection:previous }}
tag would have returned "Article A" as the previous entry and "Article B" would have been ignored.Similarly, when you visited the "Article B" entry, the
{{ collection:next }}
tag would have returned "Article D" as the next entry and "Article C" would have been ignored.This PR fixes this issue by querying both entries before/after the current entry's date AND those on the same date where the title is greater/less than the current entry's title.
To make this work, ensure you have two sorts configured on the previous/next collection tag. The first being the
date
field and the second being the secondary column you want to order by, in my case that's thetitle
.Fixes #1831.