where
Select all objects in an array where the attribute (first argument) returns a certain value (second argument). The default comparison operator is ==
(equal to), but you can pass another operator as the third argument. You can choose from:
==
(equal to)!=
(not equal to)>
(greater than)<
(less than)>=
(greater than or equal to)<=
(less than or equal to)contains
(contains substring in String or a certain object in Array)
Returns all posts that have ‘Only this title’ as the title.
Returns all posts that have the passed category as category. In this case post.categories
returns an array, so the contains
operator must be used.
You can also compare by date and time, which gets parsed automatically when the passed attribute name returns a date. The words now
or today
are parsed as the current time.
Logical operators, and/or
You can pass more than three arguments to the where filter, to use multiple rules to compare in the selection. Every third argument is the comparison operator and is optional. E.g. passing
returns the same result as
Returns every post that has “Only this title” as the title OR is created before March 25 2018.
If you want to have only the posts that have the title AND are created before March 25 2018, you can chain the filter like this: