Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Kirby CMS Snippets: pagination with page numbers.
<? if ($articles->pagination()->hasPages()): ?>
<ul class="pagination">
<? if($articles->pagination()->hasNextPage()): ?>
<li><a class="prev" href="<?= $articles->pagination()->nextPageURL() ?>">Older posts</a></li>
<? endif; ?>
<? foreach($articles->pagination()->range(5) as $paging): ?>
<li><a href="<?= $articles->pagination()->pageURL($paging); ?>"><?= $paging; ?></a></li>
<? endforeach ?>
<? if($articles->pagination()->hasPrevPage()): ?>
<li><a class="next" href="<?= $articles->pagination()->prevPageURL() ?>">Newer posts</a></li>
<? endif; ?>
</ul>
<? endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment