Reference

Guide

$page->prev()

Returns the previous item in the collection if available

$page->prev(): Model|null

Return type

Model|null

Example

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

Using sort field

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

Source code

kirby/src/Cms/HasSiblings.php#L52