Hello guys, I'm trying to create a "next button" for the posts on my site but when I reach the last post I get an error, anyhow I can get the first post when there's no more posts left?
Welcome to the Prismic community, and thanks for reaching out to us.
If I understand your question well, you want to use the first post in case there is no post left. In this case, you will have to send a new query to retrieve the first result when the last post is retrieved from the query.
Steps:
Check if the result_size is zero or not.
If it is zero, then send a new request for retrieving the first element. (by removing the after parameter from the query and setting page size as 1)
If it is not zero, then retrieve the result.
Let me know if you have any further questions.
Thanks,
Priyanka
system
(system)
closed as resolved, flag & select 'Something Else' to reopen.
6
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.