Table of Contents
The operators attribute allows you to define how each search value is compared to its corresponding field in the search attribute. It should be a comma-separated list, with each operator matching its position to the same-positioned field ID in the search attribute.
Supported Operators #
| Operator | Meaning |
|---|---|
= or is |
Equals |
!=, isnot, is not |
Not equal to |
contains |
Partial match |
like |
SQL-style LIKE with custom wildcards |
in |
Value is in array |
notin, not in |
Value is NOT in array |
gt |
Greater than |
lt |
Less than |
gt= |
Greater than or equal to |
lt= |
Less than or equal to |
*To compare against multiple values using
inornot in, pass a PHP-style array in the shortcode content, like:array('item one', 'item two', 'item three')
Operator Matching Behavior #
Each operator in operators must match the position of a field in the search attribute:
-
If you pass fewer operators than
searchfields:- The remaining fields default to
=(exact match). - This lets you apply advanced filters only where needed.
- The remaining fields default to
-
If you pass more operators than
searchfields:- Extra operators are ignored.
-
If
operatorsis omitted entirely:- All search fields use
=by default.
- All search fields use
Examples #
Basic match with mixed operators
[gravops_search target="1" search="3,5,8" operators="contains,=,gt"]
Smith|john@example.com|50
[/gravops_search]
- Field 3 must contain “Smith”
- Field 5 must equal “john@example.com“
- Field 8 must be greater than 50
Using array for in
[gravops_search search="5" operators="in"]
array('yes','maybe')
[/gravops_search]
- Field 5 must match one of the given values
Mixing defaults and explicit operators
[gravops_search search="3,5,8" operators="contains"]
Smith|john@example.com|50
[/gravops_search]
- Field 3 uses
contains - Field 5 and 8 default to
=
Tips & Gotchas #
- Array format: Use
array('one','two')exactly—do not just write comma-separated values. - Order matters: Ensure your
operatorsmatch the order ofsearchfields. - If a field is repeated in
search, you can still assign distinct operators per instance.