$page->index() method

Return the index/position of this page relative to siblings.

If given a hidden or unpublished page, that page would not usually be part of the group of siblings. As a result, such pages will return what the value would be if they were visible (as of 3.0.121). This may overlap with the index of other pages, since indexes are relative to visible pages, unless you specify an include mode (see next paragraph).

If you want this method to include hidden/unpublished pages as part of the index numbers, then specify boolean true for the $selector argument (which implies "include=all") OR specify a selector of "include=hidden", "include=unpublished" or "include=all".

Available since version 3.0.24.


$i = $page->index();
$n = $page->parent->numChildren();
echo "This page is $i out of $n total pages";


// basic usage
$int = $page->index();

// usage with all arguments
$int = $page->index($selector = '');


selector (optional)

Return value


Returns index number (zero-based)

$page methods and properties

API reference based on ProcessWire core version 3.0.160

Twitter updates

  • ProcessWire 3.0.161 adds support for selector operator stacking, enabling you automatically broaden searches in a single pages.find() call— More
    26 June 2020
  • ProcessWire 3.0.160 adds powerful new text-searching operators, bringing a new level of power to page-finding API calls, especially when it comes to search engine type queries. Post also includes a demo search engine where you can test it all out live— More
    19 June 2020
  • Preview of ProcessWire 3.0.160 with auto-enable of two-factor authentication, new version of TfaEmail and TfaTotp, and new selector operators coming next week. More
    12 June 2020

Latest news

  • ProcessWire Weekly #320
    In the 320th issue of ProcessWire Weekly we're going to check out the latest core updates (ProcessWire 3.0.161), a new third party module called Fieldtype Runtime only, an IndieWeb themed article from Francesco Schwarz, and more. Read on!
    Weekly.pw / 27 June 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

“Indeed, if ProcessWire can be considered as a CMS in its own right, it also offers all the advantages of a CMF (Content Management Framework). Unlike other solutions, the programmer is not forced to follow the proposed model and can integrate his/her ways of doing things.” —Guy Verville, Spiria Digital Inc.