It seems Thye are not Providing that Out of the box
I have created snippets which can do that work.
In you page's code block
add this code snippet [ next previous
works based on published_at
field (Published on in form) ]
public function nextPost($post) {
// get current cats
$postCats = $post->categories->pluck('id')->toArray();
// Here you need to pass it as we are
// hardcoding category slug in URL so we have no data of category
// IF YOU DONT WANT CAT COME FROM POST
// YOU CAN HARD CODE THEM $postCats = ['2']
// here 2 is id of category
// use this cats to scope
$nextPost = $post->isPublished()->applySibling(-1)
->FilterCategories($postCats)->first();
// check if next is not availabe then return false
if(!$nextPost) {
return false;
}
// create page link here same page
$postPage = $this->page->getBaseFileName();
// set URl so we can direct access .url
$nextPost->setUrl($postPage, $this->controller);
// set Cat URl so we can use it directly if needed
$nextPost->categories->each(function($category) {
$category->setUrl($this->categoryPage, $this->controller);
});
return $nextPost;
}
public function previousPost($post) {
// get current cats
$postCats = $post->categories->pluck('id')->toArray();
// IF YOU DONT WANT CAT COME FROM POST
// YOU CAN HARD CODE THEM $postCats = ['2']
// here 2 is id of category
// use this cats to scope
$prevPost = $post->isPublished()->applySibling(1)
->FilterCategories($postCats)->first();
// check if nprevious ext is not availabe then return false
if(!$prevPost) {
return false;
}
// create page link here same page
$postPage = $this->page->getBaseFileName();
// set URl so we can direct access .url
$prevPost->setUrl($postPage, $this->controller);
// set Cat URl so we can use it directly if needed
$prevPost->categories->each(function($category) {
$category->setUrl($this->categoryPage, $this->controller);
});
return $prevPost;
}
In Markup area
you can add this code.
{% component 'blogPost' %}
{% set nextPostRecord = this.controller.pageObject.nextPost(blogPost.post) %}
{% set previousPostRecord = this.controller.pageObject.previousPost(blogPost.post) %}
{% if previousPostRecord %}
<a href="{{ previousPostRecord.url }}"> Previous </a>
{% endif %}
{% if nextPostRecord %}
<a href="{{ nextPostRecord.url }}"> Next </a>
{% endif %}
This will respect category
and show only that category posts
If any doubt please comment.