Jump to content

Trying to found page->children


ankh2054
 Share

Recommended Posts

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 :)

Link to comment
Share on other sites

$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
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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