$pages->getByIDs() method

Given array or CSV string of Page IDs, return a PageArray

Available since version 3.0.156. Previous versions can use $pages->getById() for similar behavior


// basic usage
$items = $pages->getByIDs($ids);

// usage with all arguments
$items = $pages->getByIDs($ids, array $options = []);


idsarray, string, WireArray

Any one of the following:

  • Single page ID (string or int)
  • Array of page IDs
  • Comma or pipe-separated string of page IDs
  • Array of associative arrays having id and templates_id: [ [ 'id' => 1, 'templates_id' => 2], [ 'id' => 3, 'templates_id' => 4 ] ]
options (optional)array

Options to affect behavior. The 'template' option is recommended when you have this info available.

  • template (Template|int|string): Template object, name or ID to use for loaded pages. (default=null)
  • parent (Page|int|string): Parent Page object, ID, or path to use for loaded pages. (default=null)
  • cache (bool): Place loaded pages in memory cache? (default=true)
  • getFromCache (bool): Allow use of previously cached pages in memory (rather than re-loading it from DB)? (default=true)
  • getNumChildren (bool): Specify false to disable retrieval and population of 'numChildren' Page property. (default=true)
  • getOne (bool): Specify true to return just one Page object, rather than a PageArray. (default=false)
  • autojoin (bool): Allow use of autojoin option? (default=true)
  • joinFields (array): Autojoin the field names specified in this array, regardless of field settings (requires autojoin=true). (default=empty)
  • joinSortfield (bool): Whether the 'sortfield' property will be joined to the page. (default=true)
  • findTemplates (bool): Determine which templates will be used (when no template specified) for more specific autojoins. (default=true)
  • pageClass (string): Class to instantiate Page objects with. Leave blank to determine from template. (default=auto-detect)
  • pageArrayClass (string): PageArray-derived class to store pages in (when 'getOne' is false). (default=PageArray)
  • pageArray (PageArray|null): Populate this existing PageArray rather than creating a new one. (default=null)
  • page (Page|null): Existing Page object to populate (also requires the getOne option to be true). (default=null)

Return value

PageArray Page

Returns PageArray unless the getOne option was specified in which case a Page is returned.

$pages methods and properties

API reference based on ProcessWire core version 3.0.167

Twitter updates

  • This week a 2nd new module for processing Stripe payments has been added to FormBuilder. Unlike our other Stripe Inputfield, this new one supports 3D Secure (SCA) payments. We’ll take a closer look at it in this post, plus a live demo— More
    16 October 2020
  • Quick weekly update covering this week's commits for the upcoming 3.0.167 ProcessWire core version— More
    18 September 2020
  • This week ProcessWire version 3.0.166 is released on the dev branch. In this post we’ll cover all that’s new relative to the previous version, 3.0.165. Plus we’ll check out the latest new versions of ProCache and FormBuilder— More
    11 September 2020

Latest news

  • ProcessWire Weekly #336
    In the 336th issue of ProcessWire Weekly we're going to introduce the Stripe action for FormBuilder, highlight some recent forum topics and other online resources, and more. Read on!
    Weekly.pw / 17 October 2020
  • Stripe Payment Processor for FormBuilder
    This week a second new module for processing Stripe payments has been added to FormBuilder. We’ll take a closer look at it in this blog post, plus we’ve got a demo of it here too.
    Blog / 16 October 2020
  • Subscribe to weekly ProcessWire news

“The end client and designer love the ease at which they can update the website. Training beyond how to log in wasn’t even necessary since ProcessWire’s default interface is straightforward.” —Jonathan Lahijani