$page->prev('date', 'desc') does'nt seems to work

I want to use prev and next buttons to navigate through my pages (but i want them to sort by the date-field which is in my template). But this doesn’t work for me.

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

The prev() and next() methods do not accept a parameter.

I created custom methods for this purpose:

Hi, thanks,
what’s the syntax i need to use?

if($prev = $page->getPrev('date, desc')){

No, you need to pass the sorted collection

sorry, i must be doing something wrong. I get an error that $prev is null. :thinking:

$collection = $page->parent()->children()->listed()->sortBy('date','desc');
echo $prev->title();

I have to look into later, don’t have the time right now…

I made it work, you can close this issue.