Skip to content

Kirby 6.0.0

$pages->find()

Find one or multiple elements by id

$pages->find(string|list ...$keys): Page|Pages

Parameters

Name Type Default Description
...$keys stringorlist<string> no default value One or more keys, or a single array of keys

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>