25th Jul '23
/
0 comments

At Least 1 Search Result Condition in Bricks

This Pro tutorial shows how the new Element Conditions API added in Bricks builder v1.8.4 can be used to register a custom condition that enables us to render elements in the search results template depending on whether there is at least one search result or not.

Applying the condition on a Section that has a query loop for showing a grid of (matching) posts:

Applying the condition on a Section that should be output only when there are no search results:

Add the following in child theme's functions.php or a code snippets plugin:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 610 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Render an element having a specific HTML ID based on value of a custom field

Render an element having a specific HTML ID based on value of a custom field

This tutorial provides the steps to use Bricks' bricks/element/render filter to conditionally output an element that has the specified HTML ID based on the value…
Categories:
Pro
Day of Week Condition in Bricks

Day of Week Condition in Bricks

Displaying elements conditionally based on the current day of the week.
Categories:
Pro
Condition for checking Bricks content

Condition for checking Bricks content

Only outputting Bricks content when a Page is built with Bricks, otherwise display WP content.
Categories:
Pro
ACF Repeater sub field value dynamic data condition in Bricks

ACF Repeater sub field value dynamic data condition in Bricks

This Pro tutorial provides the steps to output an element on single posts (can be of any post type) only if a specified ACF (Pro)…
Condition for Checking Current Post Category in Bricks

Condition for Checking Current Post Category in Bricks

How we conditionally display an element based on the current post's categories.
Categories:
Conditionally Outputting Based on Query Count in Bricks

Conditionally Outputting Based on Query Count in Bricks

Update on 22 Sep 2023: There's a much simpler built-in method now. See this post. In the Bricks Facebook group a user asks: Is there…
Categories:
JetEngine Checkbox Condition in Bricks

JetEngine Checkbox Condition in Bricks

How elements in Bricks can be conditionally output depending on the selected option from a JetEngine checkbox field.
Categories:
Tags: