# Count children on specific page

**URL:** https://forum.getkirby.com/t/count-children-on-specific-page/10359
**Category:** Questions
**Tags:** v2
**Created:** [May 7, 2018, 1:57pm UTC](https://forum.getkirby.com/t/count-children-on-specific-page/10359 "2018-05-07T13:57:37Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mafleig](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mafleig/32/15806_2.png) [@mafleig](https://forum.getkirby.com/u/mafleig)
#### Post date: [May 7, 2018, 1:57pm UTC](https://forum.getkirby.com/t/count-children-on-specific-page/10359/1 "2018-05-07T13:57:37Z")

</div>

I´d like to count the children of a specific page, like here:

```
 <?= $page->find('journal')->children()->count() ?>

```

but I get following error:

Error  
Call to a member function children() on boolean

What can i do?

---

<div class="post-metadata">

### Author: ![thguenther](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/thguenther/32/16708_2.png) [@thguenther](https://forum.getkirby.com/u/thguenther)
#### Post date: [May 7, 2018, 2:04pm UTC](https://forum.getkirby.com/t/count-children-on-specific-page/10359/2 "2018-05-07T14:04:46Z")

</div>

Is the `journal` page a root page? Then you can simply use:

`<?= page("journal")->children()->count() ?>`

---

<div class="post-metadata">

### Author: ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)
#### Post date: [May 7, 2018, 2:15pm UTC](https://forum.getkirby.com/t/count-children-on-specific-page/10359/3 "2018-05-07T14:15:24Z")

</div>

> [@mafleig](#):
>
> $page-\>find(‘journal’)

In addition to @thguenther solution:  
The reason why this error appears is that you try to find a page in $page. But $page refers to the current page and `find()`is not a page but a collection/pages method-

So you can either use the page() helper as suggested, or search for the page in the $pages object:

```auto
<?= $pages->find('journal')->children()->count() ?>

```

However, it is a best practice to make sure that you really have a page object before you call any methods on it:

```auto
if($p = page('journal')) {
  echo $p->children()->count();
}

```

---

<div class="post-metadata">

### Author: ![mafleig](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mafleig/32/15806_2.png) [@mafleig](https://forum.getkirby.com/u/mafleig)
#### Post date: [May 7, 2018, 4:37pm UTC](https://forum.getkirby.com/t/count-children-on-specific-page/10359/4 "2018-05-07T16:37:42Z")

</div>

Thanks 🙂 Worked perfectly. And it was a big help to get more into php.

---

<div class="post-metadata">

### Author: ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)
#### Post date: [February 6, 2025, 5:28pm UTC](https://forum.getkirby.com/t/count-children-on-specific-page/10359/5 "2025-02-06T17:28:17Z")

</div>


