Reference

Guide

$pages->limit()

Returns a new object with a limited number of elements

$pages->limit(int $limit): Kirby\Toolkit\Collection

Parameters

Name Type Default Description
$limit int

The number of elements to return

Return type

Kirby\Toolkit\Collection

Example

<h2>Latest subpages</h2>
<ul>
  <?php foreach($page->children()->limit(3) as $subpage): ?>
  <li>
    <a href="<?= $subpage->url() ?>">
      <?= html($subpage->title()) ?>
    </a>
  </li>
  <?php endforeach ?>
</ul>

Inherited from

Kirby\Toolkit\Collection

Source code

kirby/src/Toolkit/Collection.php#L602