$page->count() method

Returns number of children page has, affected by output formatting mode.

  • When output formatting is on, returns only number of visible children, making the return value the same as the Page::hasChildren() method.

  • When output formatting is off, returns number of all children without exclusion, making the return value the same as the Page::numChildren() method.

Example

// Get number of visible children, like $page->hasChildren()
$page->of(true); // enable output formatting
$numVisible = $page->count();

// Get number of all children, like $page->numChildren()
$page->of(false); // disable output formatting
$numTotal = $page->count();

Usage

$int = $page->count();

Return value

int

Quantity of children

See Also


$page methods and properties

API reference based on ProcessWire core version 3.0.137

Twitter updates

  • ProcessWire 3.0.144 and 3.0.145 add improved field template context override settings and include a new Inputfields API, along with numerous other issue fixes, optimizations and improvements to the core. More
    8 November 2019
  • ProcessWire 3.0.144 core updates: Upgraded overrides section in the field editor, a new Inputfields JS API, and more— More
    1 November 2019
  • ProcessWire 3.0.143 core updates — 26 commits and 18 resolved issue reports, plus some other useful improvements and additions. More here: More
    25 October 2019

Latest news

  • ProcessWire Weekly #288
    In the 288th issue of ProcessWire Weekly we'll cover the latest core updates, introduce WireMailSendGrid, host a new weekly poll, and showcase a new site of the week. Read on!
    Weekly.pw / 16 November 2019
  • ProcessWire 3.0.145 core updates
    ProcessWire 3.0.144 and 3.0.145 add improved field template context override settings and include a new Inputfields API, along with numerous other issue fixes, optimizations and improvements to the core.
    Blog / 8 November 2019
  • Subscribe to weekly ProcessWire news

“…building with ProcessWire was a breeze, I really love all the flexibility the system provides. I can’t imagine using any other CMS in the future.” —Thomas Aull