Skip to content

Kirby 5.0.4

$pages->count()

Counts all elements

$pages->count(): int

Return type

int

This method modifies the existing $pages object it is applied to and returns it again.

Parent class

Kirby\Cms\Pages inherited from Kirby\Toolkit\Iterator

Examples

Counting first level pages

The site has <?= $pages->count() ?> main pages

Counting subpages

This page has <?= $page->children()->count() ?> subpages

Counting all pages

The site has <?= $site->index()->count() ?> pages in total