View Categories

Using Search Operators

The operators attribute allows you to define how each search value is compared to its corresponding field. It should be a comma-separated list, with each operator matching its position to the combined search sequence: search field IDs first, then search_label entries, then search_type entries.

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 in or not 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 matches by position across the full combined search sequence: search field IDs first, then search_label entries (in order), then search_type entries (in order).

  • If you pass fewer operators than the total number of search positions, the remaining positions default to = (exact match).
  • If you pass more operators than positions, extra operators are ignored.
  • If operators is omitted entirely, all search positions use = by default.

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 equaljohn@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 operators match the order of search fields.
  • If a field is repeated in search, you can still assign distinct operators per instance.