Home Forums General Issues Relationship Field and Prev/Next Posts Reply To: Relationship Field and Prev/Next Posts

  • You cannot use the built in previous and next post links because the post being shown is not related to other posts in the DB, it is related to other posts in a relationship field in ACF.

    The major issue here is “what relationship field”. You could have several relationship fields. How do you know that someone clicked on a related post link in another post to get to the current post? What relationship field did was used to show that link?

    So you need 2 pieces of information that are not readily available when a post is shown.

    1. The originating post where the related posts were originally shown
    2. the relationship fields used to show those related posts

    Given this information you would get the relationship field from the original post and loop though the posts in that relationship field to determine the post before and after the current post in that field.