$page->child() method

Return the page’s first single child that matches the given selector.

Same as $page->children() but returns a single Page object or NullPage (with id=0) rather than a PageArray. Meaning, this method will only ever return one Page.

Example

// Get the newest created child page
$newestChild = $page->child("sort=-created"); 

Usage

// basic usage
$page = $page->child();

// usage with all arguments
$page = $page->child($selector = '', array $options = []);

Arguments

NameType(s)Description
selector (optional)string, array, int

Selector to use, or blank to return the first child.

options (optional)array

Optional options per Pages::find

Return value

See Also


$page methods and properties

API reference based on ProcessWire core version 3.0.163

Twitter updates

  • ProcessWire 3.0.163 resolves more than a dozen issue reports and adds new hooks and configurable module install options, among numerous other updates. In addition, a major update to ProCache (v4.0) has been released— More
    24 July 2020
  • Weekly update for 17 July 2020 and a look at new features coming in next week's version of ProCache— More
    17 July 2020
  • ProcessWire 3.0.162 continues improvements to selector operators, fixes various minor issues, adds new API convenience methods, improves documentation, optimizes and refactors various portions of code and DB queries, and more— More
    10 July 2020

Latest news

  • ProcessWire Weekly #325
    In the 325th issue of ProcessWire Weekly we're going to cover a new master version of ProcessWire, introduce the Textformatter Audio Embed module, and more. Read on!
    Weekly.pw / 1 August 2020
  • Powerful new text-searching abilities in 3.0.160
    In ProcessWire 3.0.160 we’ve got some major upgrades and additions to our text-search abilities. This brings a whole new level of power to $pages->find() and similar API calls, especially when it comes to search engine type queries.
    Blog / 19 June 2020
  • Subscribe to weekly ProcessWire news

I just love the easy and intuitive ProcessWire API. ProcessWire rocks!” —Jens Martsch, Web developer