Skip to content

Kirby 3.9.8

$pages->limit()

Returns a new object with a limited number of elements

$pages->limit(int $limit): Kirby\Cms\Pages

Parameters

Name Type Default Description
$limit * int The number of elements to return

Return type

Kirby\Cms\Pages

This method does not modify the existing $pages object but returns a new object with the changes applied. Learn more →

Parent class

Kirby\Cms\Pages inherited from 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>