Skip to content

Fetching prev/next posts #306

Answered by jmikrut
JarrodMFlesch asked this question in Q&A
Discussion options

You must be logged in to vote

It seems to me like your code should actually work to do what you want. Does it work, for the most part? Outside of where you're saying:

I think my problem is when I am querying the first / last post. If I'm on the last post, the next post should be the first post.

If it works up to that point, and say you are on the last post with no first post, you'd just need to fetch the first post and use that manually. If this does not work at all, it might be a lower level issue. I've never personally tried to sort on IDs but I will do some digging if this should work and does not.

Is it possible to access the collection slug that is calling the hook? That would allow this hook to be reusable ac…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@JarrodMFlesch
Comment options

Answer selected by JarrodMFlesch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants