Layouts/Loopers: How to display posts based on an ACF date picker?

Hi Themeco,

I have a CPT called Casting Call. On the Casting Calls archive layout page I want to show only the casting calls for upcoming productions (and hide the past ones). How to achieve this?

Using ACF, I created a date picker field called “production_date”. I want the looper to only display the casting calls that have a production_date later than today’s date.

When setting up the looper provider, I chose Query Builder, then chose posts: “Casting Call”. There is a date function but it only seem to work with the post publication date, not a datepicker custom field such as production_date.

I tried using the conditions in the looper consumer, such as
{{dc:global:date}} BEFORE {{dc:acf:post_field field=“production_date”}}
but it doesn’t seem to work.

I am hoping you can help me with this! I think I am in the right direction, but I am missing something somewhere. Thanks a lot!

Hi @andrewamj,

Thanks for reaching out.
You need to specify the Publish After and Publish Before using the Dynamic Content from ACF. Please find the detailed documentation on how you can get the ACF field data using the Dynamic Content.

Hope it helps.

Hi @tristup,

Thanks for the quick reply! The Published After and Published Before sections seem to only work with the actual date/time the post was published through Wordpress. In my case, a Case Study post might have been “published” yesterday, but the production_date could be a few weeks from now. In this case the Published After and Published Before dates do not seem to work.

Is there a way to use another looper provider type instead of “Query Builder”? If so, what is the best way to show only the posts that have a production_date today or a later date?

Screen Shot 2021-05-19 at 12.54.56 PM

Thanks a lot!

Hello @andrewamj,

You will need to run a Query String instead. For example:

post_type=casting_call&meta_key=production_date&meta_value=date('Y m d')&meta_compare=<=

The meta_value should be the same format as the return format of your custom field settings. You will have to use meta_compare. For more information, please check this out:

Hope this helps.

Hi @ruenel,

Thanks so much, the Query String seems to be exactly the way to go, once set up properly.

I tried using the string in your example, and made sure the date format is the same in the custom field settings: ‘Ymd’

However it seems like it does not output the posts as intended.

If I compare using “>” it shows nothing

If I compare using “<” it shows all my posts, regardless of the value of production_date

What am I missing? We’re so close :slight_smile:

Thanks a lot for your help!! Much appreciated

Hi @andrewamj,

It showing nothing as you are comparing the date value greater than current date. I suggest you use the BETWEEN comparison for the production_date value like the following.


You can also try by using the date_query, please go through the following article on it.

And also go through the following article by my colleague Kory to construct the query for the Query String while using the date_query.

Hope it helps.

Hi @tristup,

Thanks for the reply! I would greatly appreciate if you could send me the full Query String so I can copy/paste it.

A bit like how @kory sent the full string in the article you sent me:


The inline query string syntax is still unclear to me. Not sure when to add the various “%5B0%5D%5B” etc…


Hello @andrewamj,

The query could be like this:

$query = array(
    'post_type'    => 'casting_call',
    'meta_key'     => 'production_date',
    'meta_value'   => date('Ymd'), // change to how "production date" is stored
    'meta_compare' => '>',

Using the @Kory’s solution in the article, we get this:


I went ahead and applied this to your Casting Call layout. It should be displaying the correct items now.

And if your order the items by production date, your Query will be like this:

$meta_query[] = array(
    'key'     => 'production_date',
    'value'   => date('Ymd'),
    'compare' => '>',
$query = array(
    'post_type'  => 'casting_call',
    'meta_key'   => 'production_date',
    'orderby'    => 'meta_value_num',
    'order'      => 'ASC',
    'meta_query' => $meta_query
var_dump( http_build_query( $query ) );

by which will give your this query string:

Hope this helps.

Hi @ruenel,

Thanks so much. this seems to be working perfectly!!!

How can I show a message “There are currently no casting calls available” if there are no casting calls that correspond to this Query? I assume we would use the conditions.

Thanks a lot!!

Hello @andrewamj,

You can use this {{dc:looper:count}} dynamic code to get the total count of the looper query result(Post count). Now you can use the condition to on an element like text or Headline element where you added your message.

Please have a look at the given screenshot.

In case if you have not seen the doc of condition operator please have a look at it.

Hope it helps

Hi Guys,
love your work.
Using this query to check event end display date against current date. For some reason - it’s not working.
In my query builder, i have entered the following:
I have also tried: category_name=events&post_type=post&meta_key={{dc:acf:post_field field=“end_display”}}&meta_value=date(‘Ymd’)&meta_compare=>=

Could you guys please assist?

Hello @etheodore,

Please use this one:


This was taken from this query:

$query = array(
    'post_type'    => 'post',
    'category_name' => 'events',
    'meta_key'     => 'end_display',
    'meta_value'   => date('Ymd'), // change to how "end_display" is stored
    'meta_compare' => '>',

Kindly let us know how it goes.

Thank you, that does work but how do i get current date in to the query in place of 20210524.

Thanks - full string used successfully is:

post_type=post&category_name=events&meta_key=end_display&meta_value={{dc:global:date format=“Ymd”}}&meta_compare=%3E

Thank you once again for your assistance.

We are delighted to assist you with this.


This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.