21st Aug '25
/
0 comments

Querying Posts by Date Field to Exclude Past Events with ACPT Plugin

In the Bricks’ Facebook group, a user asked:

Meta query? What am I missing?

Hi all, really need a little guidance on this one. I have a CPT called tradeshows, set up with ACPT. I have a loop showing them, but I would like to have the ones that the “End Date” has passed the current date to drop off and not be a part of the loop. I have tried so many combinations my head is spinning. Nothing is working. The field for the “end date” is {acpt_tradeshows_trade-show_end-date} I have tried Numeric instead of date for type, nothing is working. Please ask if theres anyhting I’m not sharing that might be helpful. Thank you!

The key to remember is that with ACPT, the date field is not stored as a Y-m-d string or a timestamp and hence can’t be used for direct comparisons in WP meta queries per my understanding.

While it is possible to use a custom function to convert the string to a timestamp or Y-m-d date and use it in Bricks query loop settings, the simpler approach is to change the date format in the advanced field settings to yyyy-mm-dd (it is the same as Y-m-d).

Next, edit all the posts and save them to update the date format.

Finally, configure your query loop in the Bricks editor like this:

{current_wp_date:Y-m-d}

This will ensure that past events are not shown.

Before:

After:

Get access to all 610 Bricks code tutorials with BricksLabs Pro

Leave the first comment

 

Related Tutorials..

Pro
Limit the Number of Posts in a Bricks Query Loop of Relationship Type

Limit the Number of Posts in a Bricks Query Loop of Relationship Type

Updated on 12 Dec 2023 Bricks Query Loop popup does not have a control for setting the number of posts to be output when the…
Pro
“My Favorites” in Bricks

“My Favorites” in Bricks

This Pro tutorial provides the steps to set up and use My Favorites in Bricks Builder.
Categories:
Pro
Query Loop Index in Bricks

Query Loop Index in Bricks

This Pro tutorial provides the code for getting the index of each post in Bricks' query loops. This can be used for either outputting the…
Categories:
Adding any Custom WP_Query loop to Bricks’ Query Loop

Adding any Custom WP_Query loop to Bricks’ Query Loop

Sometimes we may need to create a custom post loop using Bricks' query loop feature, but wish to use our own WP_Query code for more…
Pro
Adjacent Posts Bricks Query Loop

Adjacent Posts Bricks Query Loop

This Pro tutorial provides the steps to customize a posts query loop in Bricks to show previous and next posts on single post pages. The…
Categories:
Pro
Events grouped by months within years based on event date custom field value

Events grouped by months within years based on event date custom field value

How to output events grouped by years and months using three nested query loops in Bricks.
Categories: