Traverse posts of the same tag with `prev_post` & `next_post`


#1

Is it possible for prev_post & next_post to traverse posts with the same primary tag?

I have a collection for photos with a custom template. I would like to setup previous and next buttons to browse images. At the moment, it also navigates to other non-photo-tagged posts.


#2

Yep, it’s documented here:


#3

Should have scrolled! Thanks Hannah!


#4

Adding the in attribute doesn’t seem to work. Other posts still appear while traversing.

I’ve checked that the posts really do have a primary tag.

It should be noted that the posts are in a collection which filters for the same tag.

collections:
  /photos/:
    template: photos
    permalink: /photos/{id}/
    filter: tag:photos