Skip to content

Kirby 4.5.0

$page->grandChildren()

Returns a collection of all published children of published children

$page->grandChildren(): Kirby\Cms\Pages

Return type

Kirby\Cms\Pages

Parent class

Kirby\Cms\Page

Example structure

  • blog
    • 2012
      • article-a
      • article-b
      • article-c
    • 2013
      • article-d
      • article-e
      • article-f
    • 2014
      • article-g
      • article-h
      • article-i

Example code

<ul>
  <?php foreach(page('blog')->grandChildren() as $item): ?>
  <li>
    <a href="<?= $item->url() ?>">
      <?= html($item->title()) ?>
    </a>
  </li>
  <?php endforeach ?>
</ul>

Result

The code above will give you a list like this:

  • Article A
  • Article B
  • Article C
  • Article D
  • Article E
  • Article F
  • Article G
  • Article H
  • Article I