Count children on specific page

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

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

but I get following error:

Call to a member function children() on boolean

What can i do?

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

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

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:

<?= $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:

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

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