Updated on 1 Aug 2024
Looking to have a Section or other elements in Bricks rendered on the frontend only if today’s date is before or matches or is after the value of a Date-type of custom field created using ACF? This Pro tutorial is for you.
Step 1
Set the Return Format of your Date field to Ymd.
Note: This article is for the case when the custom fields group is attached to a single post/CPT.
Step 2
Whitelist the wp_date function.
Ex.:
<?php
add_filter( 'bricks/code/echo_function_names', function() {
return [
'wp_date'
];
} );
You should also add other functions (native or custom) being used in your Bricks instance besides wp_date. This can be checked at Bricks → Settings → Custom code by clicking the Code review button.
More info on whitelisting can be found here.
Step 3
In your single post/CPT Bricks template, apply this condition for your Section or other element(s):

In
{acf_banner_start}
replace banner_start with the name of your custom field.
For today’s date:
{echo:wp_date(Ymd)}
Change the operator from == to < or <= or > or >= as needed.