Skip to content
Get Bricks

Element Conditions Schema

Element display conditions control whether an element renders on the frontend. They are stored in the _conditions key inside any element’s settings object.

Conditions use an OR-of-AND structure: the outer array contains OR groups, and each inner array contains AND items. The element renders if any OR group evaluates to true, and an OR group is true when all its AND items are true.

{
"type": "array",
"description": "Element display conditions. Controls whether the element renders. Outer array is OR groups, inner arrays are AND items. The element renders if any OR group evaluates to true. Extensible via bricks/conditions/groups and bricks/conditions/options filters.",
"items": {
"type": "array",
"description": "AND group: all items in this array must be true for the group to match",
"items": {
"type": "object",
"description": "A single display condition that evaluates to true or false. Combined with other items in AND groups, then OR across groups.",
"properties": {
"id": {
"type": [
"string",
"integer"
],
"description": "Unique identifier for this condition"
},
"key": {
"type": "string",
"description": "Condition type. General: browser, current_url, date, datetime, dynamic_data, featured_image, operating_system, referer, time, weekday. Post: post_author, post_date, post_id, post_parent, post_status, post_title. User: user_id, user_logged_in, user_registered, user_role. WooCommerce: woo_product_category, woo_product_featured, woo_product_new, woo_product_purchased_by_user, woo_product_rating, woo_product_sale, woo_product_sold_individually, woo_product_stock_management, woo_product_stock_quantity, woo_product_stock_status, woo_product_tag, woo_product_type. Extensible via bricks/conditions/options filter.",
"enum": [
"browser",
"current_url",
"date",
"datetime",
"dynamic_data",
"featured_image",
"operating_system",
"post_author",
"post_date",
"post_id",
"post_parent",
"post_status",
"post_title",
"referer",
"time",
"user_id",
"user_logged_in",
"user_registered",
"user_role",
"weekday",
"woo_product_category",
"woo_product_featured",
"woo_product_new",
"woo_product_purchased_by_user",
"woo_product_rating",
"woo_product_sale",
"woo_product_sold_individually",
"woo_product_stock_management",
"woo_product_stock_quantity",
"woo_product_stock_status",
"woo_product_tag",
"woo_product_type"
]
},
"compare": {
"type": "string",
"description": "Comparison operator. ==: equal, !=: not equal, >=: greater or equal, <=: less or equal, >: greater, <: less, contains: string contains, contains_not: string does not contain, empty: value is empty (no value field needed), empty_not: value is not empty (no value field needed). Available operators vary by condition key.",
"enum": [
"==",
"!=",
">=",
"<=",
">",
"<",
"contains",
"contains_not",
"empty",
"empty_not"
]
},
"value": {
"description": "Value to compare against. Not required when compare is empty or empty_not.",
"oneOf": [
{
"type": [
"string",
"number",
"integer",
"boolean",
"null"
]
},
{
"type": "object"
},
{
"type": "array"
}
]
},
"dynamic_data": {
"type": "string",
"description": "Dynamic data tag to use as the value source (e.g. {post_title})"
}
},
"additionalProperties": false
}
}
}

Each condition item has the following properties:

PropertyTypeRequiredDescription
idstring | integerYesUnique identifier for this condition
keystringYesCondition type (see enum below)
comparestringYesComparison operator (see table below)
valueanyConditionalThe value to compare against. Not needed when compare is empty or empty_not.
dynamic_datastringNoDynamic data tag to use as the value source
{
"_conditions": [
[
{ "id": "abc123", "key": "user_logged_in", "compare": "==", "value": true },
{ "id": "def456", "key": "user_role", "compare": "==", "value": "administrator" }
],
[
{ "id": "ghi789", "key": "dynamic_data", "compare": "contains", "value": "sale", "dynamic_data": "{post_title}" }
]
]
}

This reads as: show the element if (user is logged in AND is an administrator) OR (the post title contains “sale”).

General

  • browser
  • current_url
  • date
  • datetime
  • dynamic_data
  • featured_image
  • operating_system
  • referer
  • time
  • weekday

Post

  • post_author
  • post_date
  • post_id
  • post_parent
  • post_status
  • post_title

User

  • user_id
  • user_logged_in
  • user_registered
  • user_role

WooCommerce

  • woo_product_category
  • woo_product_featured
  • woo_product_new
  • woo_product_purchased_by_user
  • woo_product_rating
  • woo_product_sale
  • woo_product_sold_individually
  • woo_product_stock_management
  • woo_product_stock_quantity
  • woo_product_stock_status
  • woo_product_tag
  • woo_product_type

Available compare operators vary by condition key. For example, post_id supports math operators (==, !=, >=, <=, >, <), while user_logged_in only supports == and !=.

OperatorDescription
==Equal (loose comparison, supports arrays via intersection)
!=Not equal (loose comparison)
>=Greater than or equal
<=Less than or equal
>Greater than
<Less than
containsString contains substring
contains_notString does not contain substring
emptyValue is empty (no value field needed)
empty_notValue is not empty (no value field needed)

Condition keys and comparison operators are filterable via PHP hooks:

  • bricks/conditions/groups: add custom condition groups
  • bricks/conditions/options: add custom condition keys with their own compare operators
  • bricks/conditions/result: modify the boolean result of any individual condition evaluation

Third-party plugins can introduce additional condition keys beyond those listed above.