Day of Week Condition in Bricks

Day of Week Condition in Bricks

This Pro tutorial provides the steps to display elements in Bricks conditionally based on the specified day of the week.

This could be used for example, to automatically display a notice only on Fridays.

Step 1

Go to Settings → General and set the Timezone to the city where your site/business is based at.

Leave the Week Starts On at the default Monday. This is not mandatory since we are going to set the same in code. So it's just a way to make sure there is consistency.

Step 2

Let's add a custom function that takes a 3-letter string of the day (like Mon or Fri) as the input and returns true if today is that specified day.

Add this in your child theme's functions.php:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 526 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Checking for Post Type in Bricks

Checking for Post Type in Bricks

A way to output elements conditionally based on the current post type in the loop in Bricks.
Categories:
Checking if the current post has been published within the last x days

Checking if the current post has been published within the last x days

Looking to conditionally output an element if the current post (either in a query loop or when viewing a single post) has been published in…
Categories:
Pro
Check If The Latest Post Was Published in The Last X Minutes

Check If The Latest Post Was Published in The Last X Minutes

In this Pro tutorial we shall define a custom function that takes in the number of minutes as an argument and returns true if there…
Categories:
[Function] Current Term Has Children

[Function] Current Term Has Children

Updated on 20 Jul 2024 A user asks: I'm working on an archive template for WooCommerce products. I'm trying to hide a section if there…
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:
Weekday Condition in Bricks

Weekday Condition in Bricks

As of Bricks 1.7, the built-in "Weekday" condition does not work correctly. This is most likely due to it not taking the site's timezone (set…
Categories:
Pro
Month and Day Condition in Bricks

Month and Day Condition in Bricks

This Pro tutorial shows how we can define a custom function that takes in a month in the three-letter format (like Dec) and a day…
Categories: