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 633 Bricks code tutorials with BricksLabs Pro

Leave the first comment

 

Related Tutorials..

Pro
Recently Viewed Posts Bricks Query Loop

Recently Viewed Posts Bricks Query Loop

How to output the most recent X number of posts (any post type) viewed by the current visitor.
Categories:
Pro
Posts older than today in Bricks

Posts older than today in Bricks

How to display only posts that were published before today in a query loop.
Categories:
HappyFiles Bricks Query Loop

HappyFiles Bricks Query Loop

This tutorial explores different ways in which images from WordPress Media Library organized via HappyFiles can be pulled and shown in Bricks using query loop(s).…
Categories:
Pro
Term Parent Slug Data Attribute in Bricks

Term Parent Slug Data Attribute in Bricks

How we can set a data attributes on a child taxonomy dynamically based on the parent taxonomy.
Categories:
Pro
Displaying Gallery of SureCart Product Images with Bricks’ Query Loop

Displaying Gallery of SureCart Product Images with Bricks’ Query Loop

Custom query loop for looping through SureCart product images.
Categories:
Tags: