Skip to content

Element Conditions

Element Conditions let you define one or multiple conditions for any element. Only if those conditions are met is the element rendered on the front end.

Conditions are validated server-side and are meant to filter out/not load an element based on data (post, user, dynamic data, date & time, etc.).

Not rendering an element means the element HTML doesn’t exist in the source code.

This is perfect for restricting content to logged-in users or users with a specific role (e.g., membership sites) to hide time-sensitive information according to a certain weekday/date/time, according to dynamic data, etc.

Element conditions are display logic. They are useful for hiding interface, marketing, membership, or product-state content, but they are not a replacement for server-side permissions around truly sensitive data, downloads, or actions. For example, hiding a download button removes the link from the page, but anyone who already has the file URL can still open the file. Protect private files and actions with your membership, file protection, or permission setup.

If you need full programmatic power to define your element conditions, use the bricks/element/render Bricks filter.

When editing an element, click the “Conditions” (toggle) icon in the panel header to open/close the element conditions interface. You’ll see the “Conditions” toggle icon in the structure panel if an element has conditions. Click the icon to jump right into the conditions interface for this element.

At least one set of conditions must be fulfilled to render the element. This means all conditions inside a condition “set” must be evaluated to be true.

So there is an OR relationship between condition sets and an AND relationship between conditions inside a set.

To add your first set of conditions, click the ”+” icon next to the “Conditions” title:

We now have one set with one condition. Every condition consists of the following three properties:

  • Key (post ID, user role, date, dynamic data, etc.)
  • Comparison operand (==, !=, >, <, contains, before, after, etc.)
  • Value (numeric, text, checkbox, select option(s), etc.)

Built-in condition groups include:

  • Post: post ID, title, parent, status, author, date, and featured image.
  • User: login state, user ID, registration date, and role.
  • Date & time: weekday, date, time, and datetime. These use the WordPress site timezone.
  • WooCommerce: product type, sale/new/stock states, stock quantity, stock management, sold individually, purchased by current user, featured status, rating, product categories, and product tags. This group is available when WooCommerce is active.
  • Other: cookie, inner content, dynamic data, browser, operating system, current URL, and referrer URL.

The Current URL condition includes query parameters. Browser, operating system, and referrer checks depend on request headers, so treat them as convenience targeting rules rather than trusted security checks.

Let’s say we want to show an element only to logged-in users. We’d create the following condition:

This element is only rendered when the person viewing this page is logged in.

Non-logged-in guests, bots, crawlers, etc., will not be able to see this element (as it’s not in the source code).

Notice the highlighted “Conditions” icon in the screenshot above. It’s a great indicator to see at a glance if the element you are editing has any conditions (without having to open the conditions interface).

The “Conditions” (toggle) icon is also visible next to an element in the structure panel to quickly scan for element conditions on your page. A click on it brings you right into the conditions interface.

Between a set of conditions exists an OR relation. And conditions within a set have an AND relation.

Let’s create a second set of conditions (by clicking the ”+” icon at the top-right again) to illustrate this.

The condition in this new set is fulfilled (true) if the post title is “Account”.

As there is an OR relation between condition sets, the element is rendered if (1) the user is logged in OR (2) the title of the post/page being viewed is “Account”.

Let’s extend the conditions for this element by checking if the logged-in user has been registered before the 1st of Jan 2022.

As there is an AND relation between conditions inside a set, click the ”+” button on the bottom-right of the first condition to add another condition to this first set:

You’ll also notice the vertical “AND” label between conditions inside a set.

And the horizontal “OR” label between condition sets.

This visualizes the element conditions logic.

Bricks checks each set on its own. Inside a set, it stops at the first condition that fails and moves on to the next set. A condition in one set does not apply to the other sets.

If a requirement applies in every case, add it to each set. For example, a “Download recipe card” button should appear for logged-in visitors, or on recipes that are free for everyone, but only when the recipe actually has a card file:

  • Set 1: User login is Logged in, AND Dynamic data {acf_recipe_card} is not empty
  • Set 2: Dynamic data {acf_card_access} == Everyone, AND Dynamic data {acf_recipe_card} is not empty

Without the card check in the second set, a free recipe without a card file would still render the button.

Show content only when a field has a value

Section titled “Show content only when a field has a value”

A single post template often contains sections that only some posts can fill, such as a video, a download, or a “Chef’s tip” box. Without a condition, posts that leave the field empty still render the section’s heading and an empty player or box.

Add a Dynamic data condition to the section, pick the field, and set the comparison to is not empty. Leave the value empty. The section then renders only on posts where the field has content.

Conditions panel for a Section named Video with one condition: Dynamic data, acf_recipe_video, is not empty.

is empty and is not empty are available for the Dynamic data condition. They check whether the rendered output of the tag is an empty string, so a field that was never filled in counts as empty, the same as a field that was cleared. Use is empty to show fallback content in the posts that have no value.

Except for Cookie conditions, == and != comparisons use PHP-style loose comparison and convert common boolean-like values such as true, false, 1, 0, and empty strings before comparing. Numeric comparisons (>, <, >=, <=) compare the resolved values directly.

For multi-select values such as user roles, post statuses, WooCommerce product categories, and product tags, is matches if any selected value overlaps. is not matches when there is no overlap.

The contains and does not contain comparisons are string checks. Use them for text-like values such as post titles, dynamic data output, URLs, and referrers. Both return false when the checked value is empty, so a does not contain condition hides the element on posts where the field has no value. Add a separate set with is empty if those posts should still show the element.

If you leave the comparison empty, the condition uses ==.

How to compare dynamic data against the value

Section titled “How to compare dynamic data against the value”

Certain dynamic data provider fields allow you to specify the value & label (e.g., ACF true false, Metabox checkbox list, radio, select, etc.).

To compare against the value instead, you can use the :value filter like this:

In the example above, the condition is fulfilled when the Metabox checkbox list has the blue value selected. Without the :value filter, the condition would compare against the checkbox option label.

In Bricks 2.5, the component Create properties from content workflow can add connected Dynamic data → is not empty conditions for selected content. The check uses the resolved property value, including its default. Clearing an instance’s text value therefore does not hide the element if its default still contains text. See Hide If Empty in Components for setup and button, image, and rich-text behavior.

Since Bricks 2.5, use Inner content to show or hide a parent based on the rendered output of a selected descendant. For example, hide a Related posts section, including its heading and background, when its query has no results.

  1. Build the wrapper and add the query element inside it. Give the query a clear label in the Structure panel, such as Related posts.
  2. Select the outer wrapper and open Conditions.
  3. Add a condition and choose Inner content from Other.
  4. Choose is not empty to show the wrapper when content is available, or is empty to show an empty state.
  5. Under Select element, choose the descendant whose output should control the wrapper.
  6. Save and check the frontend with both matching and empty query results.

The Related posts wrapper with Inner content set to is not empty and targeting its Journal card descendant.

Only descendants are available, including nested children and content placed in component slots. To target an element inside a component definition, edit that component. The condition does not select unrelated elements elsewhere on the page.

Bricks evaluates the selected element’s final rendered HTML after its own conditions and render filters. No output, whitespace-only output, and a single empty wrapper such as <div></div> count as empty. Empty query-pagination markers and the Posts element’s empty layout scaffolding are ignored.

An image, text, a no-results message, or nested HTML can make the result non-empty. This is an output check, not a visibility check: hiding content with CSS does not make its HTML empty. If a query has a no-results message, that message counts as content, so clear it when you want the outer wrapper to disappear completely.

If the selected target repeats in a query loop, is not empty passes when any rendered instance produces content. Other conditions in the same set still use AND, and separate sets still use OR.

The Builder keeps the wrapper visible and editable. Check the frontend to confirm the condition’s effect.

If the selected target is deleted or moved outside the wrapper, Bricks treats it as empty and the selector shows an element-not-found entry. Select another descendant to repair the condition. Duplicating or pasting a complete structure updates its target references. When pasting conditions alone, the target is retained only if it is still a descendant of the destination.

Since Bricks 2.5, the Cookie condition can check whether a named cookie is present or compare its value. Use it to tailor content to a visitor preference already stored by your site.

  1. Select the element and open Conditions.
  2. Add a condition and choose Cookie in the Other group.
  3. Enter the exact Cookie name, such as audience. Enter the name itself, without dynamic data tags.
  4. Choose a comparison. For is or is not, enter the value to compare, such as returning.
ComparisonThe condition passes when
existsThe named cookie is present, including an empty value or 0.
does not existThe named cookie is absent.
isThe cookie exists and its value exactly matches the comparison value.
is notThe cookie exists and its value differs from the comparison value.

Cookie value comparisons are case-sensitive: returning and Returning are different values. is not does not match a missing cookie. To include visitors without that cookie, add a separate OR condition set using does not exist.

For example, a welcome-back message with Cookie, name audience, comparison is, and value returning renders only when the request contains that value. The condition reads the cookie; it does not create or update it.

Cookie condition with the cookie name audience, comparison is, and value returning.

Bricks evaluates the cookie on the server when rendering the page. After changing a browser cookie, load the page again to evaluate the new value. As with other element conditions, the Builder keeps the element visible for editing.

If a full-page cache serves the page, configure it to vary by the relevant cookie or exclude that page from caching. Otherwise visitors can receive cached content produced for a different cookie value. Cookie conditions are for content targeting; use login and permission checks to protect restricted content.

Bricks 2.4 adds WooCommerce conditions for checkout and order-aware layouts:

  • Checkout : Login step needed
  • Checkout : Needs shipping
  • Checkout : Needs shipping address
  • Checkout : Order has status
  • Order : Needs shipping address
  • Order : Has downloads

Use these conditions inside WooCommerce v2 checkout, pay, thank-you, order receipt, account view-order, and other order-aware layouts when content should only appear for a matching checkout or order state.

Checkout : Login step needed is Yes only for a logged-out customer when WooCommerce > Settings > Accounts & Privacy > Enable log-in during checkout is enabled. The generated Checkout v2 multistep structure uses it to keep the Account Login navigation item, step, and Customer info Back button in sync.

Checkout : Needs shipping checks whether the non-empty cart contains products that require shipping. Use it for shipping methods and any Checkout v2 section or step that customers need to access to choose a shipping method.

Checkout : Needs shipping address checks whether WooCommerce needs a separate shipping address. This can return No when WooCommerce is set to force shipping to the billing address, even though the cart still requires shipping and customers still need to choose a shipping method.

For a Checkout v2 layout, apply Checkout : Needs shipping to the Shipping options wrapper. In a multistep layout, apply the same condition to both the Shipping step and its matching navigation item. Apply Checkout : Needs shipping address only to the Ship to another address control and shipping-address fields.

See WooCommerce v2 query loops and dynamic tags for the related WooCommerce v2 data reference.

With advanced modular elements and WooCommerce Order Withdrawal enabled, use Order withdrawal screen inside the Account Page v2 withdrawal state. Compare with Your details, Review, or Confirmation using is or is not. The generated structure includes these conditions. They control frontend output; all three sections remain visible in the builder.

The following information is intended for developers who wish to extend the default element conditions interface programmatically (@since 1.8.4).

The custom element condition should resemble the following example:

Builder: New condition group with “Post type” option

Step 1: Add condition group via filter: bricks/conditions/groups

Section titled “Step 1: Add condition group via filter: bricks/conditions/groups”
add_filter( 'bricks/conditions/groups', 'add_my_condition_group' );
function add_my_condition_group( $groups ) {
// Ensure your group name is unique (best to prefix it)
$groups[] = [
'name' => 'my_group',
'label' => esc_html__( 'My Group', 'my-plugin' ),
];
return $groups;
}

Step 2: Add condition options via filter: bricks/conditions/options

Section titled “Step 2: Add condition options via filter: bricks/conditions/options”

In this example, create a new condition to compare the current page post type with the user’s value. The compare control is a dropdown with “is” and “is not” options. The value field type is a text input.

add_filter( 'bricks/conditions/options', 'add_my_custom_condition' );
function add_my_custom_condition( $options ) {
// Ensure key is unique, and that group exists
$options[] = [
'key' => 'my_post_type',
'label' => esc_html__( 'Post Type (New)', 'my-plugin' ),
'group' => 'my_group',
'compare' => [
'type' => 'select',
'options' => [
'==' => esc_html__( 'is', 'my-plugin' ),
'!=' => esc_html__( 'is not', 'my-plugin' ),
],
'placeholder' => esc_html__( 'is', 'my-plugin' ),
],
'value' => [
'type' => 'text',
],
];
return $options;
}

Expected result: New condition in the builder

Step 3: Execute your logic to return a Boolean result via filter: bricks/conditions/result

Section titled “Step 3: Execute your logic to return a Boolean result via filter: bricks/conditions/result”

Based on your custom logic, return true or false for your condition. Bricks take care of the OR and AND conditions.

In this example, we check if the current post type matches the user value.

If the condition is met, return true.

You can access the $condition variable, which has been set inside the builder.

add_filter( 'bricks/conditions/result', 'run_my_custom_condition', 10, 3 );
function run_my_custom_condition( $result, $condition_key, $condition ) {
// If $condition_key is not 'my_post_type', we return the $render as it is
if ( $condition_key !== 'my_post_type' ) {
return $result;
}
// Now you can perform your logic by using the $condition variable
// $condition['compare'] is the compare operator, might be empty
// $condition['value'] is the user value, might be empty
// In my example, if compare is empty, we set it to '==' as default
$compare = isset( $condition['compare'] ) ? $condition['compare'] : '==';
$user_value = isset( $condition['value'] ) ? $condition['value'] : '';
$condition_met = false;
// Get the current post type of the page
$current_post_type = get_post_type();
switch( $compare ) {
case '==': // "is"
$condition_met = $current_post_type === $user_value;
break;
case '!=': // "is not"
$condition_met = $current_post_type !== $user_value;
break;
}
return $condition_met;
}

If you have added multiple options under the same group, you can target them like this:

add_filter( 'bricks/conditions/result', 'run_my_custom_condition', 10, 3 );
function run_my_custom_condition( $result, $condition_key, $condition ) {
$condition_options = \Bricks\Conditions::$options;
$registered_condition = null;
foreach ( $condition_options as $option ) {
if ( isset( $option['key'] ) && $option['key'] === $condition_key ) {
$registered_condition = $option;
break;
}
}
if ( ! $registered_condition || $registered_condition['group'] !== 'my_group' ) {
return $result;
}
// Now you can perform your logic by using the $condition variable
// $condition['compare'] is the compare operator, might be empty
// $condition['value'] is the user value, might be empty
$condition_met= false;
switch( $condition_key ) {
case 'my_condition_option_1':
// Example
$condition_met = execute_my_logic_1( $condition );
break;
case 'my_condition_option_2':
// Example
$condition_met = execute_my_logic_2( $condition );
break;
}
return $condition_met;
}