I have a page where all the results of a search are displayed, when entering one of the posts to view the content, I need to be able to link to the previous and next post within the results of that search.
Is there any documentation that you are following?
No
That's not possible. Once you have navigated to the individual post then you have lost the context of the query that produced the list of matching posts to know which would be the previous and next posts.
You would need to code a custom solution. There are a number of ways you might attempt this, but none of them are particularly efficient.
You would either need to pass details of the query (including whatever filters had been applied) to the single post so that the query could be run again to identify the previous and next posts to link to, or you could pass details of the results themselves (e.g. an array of all of the post IDs in sequence) which could also be used to determine the previous and next post IDs, though this won't work if you are using pagination.
An alternative is not to link to the actual single post, but instead to link to a page which has a similar View, but which includes pagination where it only shows one post per page, and where the View output includes all of the content that would be shown when visiting the single post directly. Users can then navigate through the View results one at a time, backwards or forwards.
The complicated part is creating the links such that they pass all of the applied filters as well as the correct page number.
Does that sound like a viable option?
The topic ‘[Closed] Link to previous or next post within the results of a filter’ is closed to new replies.