Skip to content

Kirby 5.0.4

$pages->find()

Find one or multiple elements by id

$pages->find(string ...$keys): Kirby\Cms\Page|Kirby\Cms\Pages

Parameters

Name Type Default
...$keys string no default value

Return types

Kirby\Cms\PageorKirby\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

Examples

Fetch a single subpage

<?= $page->children()->find('subpage-a')->title() ?>

Fetch multiple subpages

<ul>
  <?php foreach($page->children()->find('subpage-a', 'subpage-c', 'subpage-i') as $subpage): ?>
  <li>
    <a href="<?= $subpage->url() ?>">
      <?= html($subpage->title()) ?>
    </a>
  </li>
  <?php endforeach ?>
</ul>