Weekday Condition in Bricks

As of Bricks 1.7, the built-in “Weekday” condition does not work correctly.

Wrong output where it is Thursday on the given day when this was tested

This is most likely due to it not taking the site’s timezone (set in WordPress settings) into account.

To work around this, let’s define a custom function and use it with the Dynamic data condition.

Add the following in child theme‘s functions.php (w/o the opening PHP tag) or a code snippets plugin:

// Function to check if today is the specified (three letter format) weekday.
// Sample usage: bl_is_weekday( 'Thu' )
function bl_is_weekday( $weekday ) {
	$today = wp_date( 'D' );

	return $today === $weekday;

and apply it like this:


Replace Thu with the three-letter week you want to check against.

To output the element when it is NOT the specified weekday, check against 0 instead of 1.

Alternatively, you could simply do:


to render the element on the specified weekday.

This way, you don’t have to register a custom function.

Instant access to 390+ Bricks code tutorials with BricksLabs Pro

Leave the first comment