Reference

Guide

$page->nextListed()

Returns the next listed page if it exists

$page->nextListed(): self|null

Return type

self|null

Example

<?php if($next = $page->nextListed()): ?>
<a href="<?= $next->url() ?>">next listed page</a>
<?php endif ?>

Using sort field

<?php if($next = $page->nextListed('title', 'asc')): ?>
<a href="<?= $next->url() ?>">next listed page</a>
<?php endif ?>

Source code

kirby/src/Cms/PageSiblings.php#L102