Reference

Guide

$page->prevListed()

Returns the previous listed page

$page->prevListed(): self|null

Return type

self|null

Example

<?php if($prev = $page->prevListed()): ?>
<a href="<?= $prev->url() ?>">previous listed page</a>
<?php endif ?>

Using sort field

<?php if($prev = $page->prevListed('date', 'desc')): ?>
<a href="<?= $prev->url() ?>">previous listed page</a>
<?php endif ?>

Source code

kirby/src/Cms/PageSiblings.php#L140