Selectors::getSelectorByField() method

Get the first selector that uses given field name

This is useful for quickly retrieving values of reserved properties like "include", "limit", "start", etc.

Using $or: By default this excludes selectors that have fields in an OR expression, like "a|b|c". So if you specified field "a" it would not be matched. If you wanted it to still match, specify true for the $or argument.

Using $all: By default only the first matching selector is returned. If you want it to return all matching selectors in an array, then specify true for the $all argument. This changes the return value to always be an array of Selector objects, or a blank array if no match.


// basic usage
$selector = $selectors->getSelectorByField(string $fieldName);

// usage with all arguments
$selector = $selectors->getSelectorByField(string $fieldName, bool $or = false, bool $all = false);



Name of field to return value for (i.e. "include", "limit", etc.)

or (optional)bool

Allow fields that appear in OR expressions? (default=false)

all (optional)bool

Return an array of all matching Selector objects? (default=false)

Return value

Selector array null

Returns null if field not present in selectors (or blank array if $all mode)

Selectors methods and properties

API reference based on ProcessWire core version 3.0.185

Twitter updates

  • Great video by @jlahijani that demonstrates his ProcessWire page builder using ProFields Repeater Matrix, the new Page Autosave + Live Preview module and Uikit 3—…
    13 November 2021
  • More development on page automatic save this week, plus the addition of live preview— More
    12 November 2021
  • ProcessWire 3.0.189 core updates— More
    5 November 2021

Latest news

  • ProcessWire Weekly #394
    In the 394th issue of ProcessWire Weekly we'll share the latest ProcessWire news and updates, including some highlights from the support forum, the latest weekly update from Ryan, and more. Read on! / 27 November 2021
  • New Repeater and Repeater Matrix features
    This week we have some very useful new additions to both the core Repeater Fieldtype and the ProFields Repeater Matrix Fieldtype. This post covers all the details along with a couple of brief demonstration videos. 
    Blog / 22 October 2021
  • Subscribe to weekly ProcessWire news

“Yesterday I sent the client a short documentation for their ProcessWire-powered website. Today all features already used with no questions. #cmsdoneright—Marc Hinse, Web designer/developer