Jump to content

Recommended Posts

Posted

Hi all,

I am trying to count the child pages of the current page, but Im doing something wrong and I don't quite understand what that is.

$total = $pages->count("$page->children");

I have also tried the following

$total = $pages->count($page->children);

could someone help please :)

Posted

Found another way, but would be interested to know how it would work the other way.

<? echo count($page->children) ?>
Posted

$pages->count() is used to count pages matching given selector string, such as $pages->count("template=basic-page"). $page->children returns children of given page (PageArray object), not a selector string.

You can also use built-in property "numChildren":

<?php echo $page->numChildren; ?>
  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...