Query posts after current date

For a calendar, I would like to query posts (of custom type ‘Events’) with event dates (through a custom event date ACF field) as later than today.

How can I access today’s date and use it in a meta query comparing event_date (the slug I’m using for the relevant ACF field) and the current date?

this is what I’m using for a comparison of posts greater than a manual number, but that needs to change to a dynamic input of the current date:

Hi there @boris,

While we don’t have a ready made variable for this (will be available at some point), I would recommend using Dynamic → WordPress | Shortcode for the Meta Value with the following as a shortcode:

// shortcode function name
function shortcode_today()
    // Return the date compatible with ACF date format
    return date('Ymd');
// register the shortcode name with shortcode function name
add_shortcode('today_date', 'shortcode_today');

Hope that helps :slight_smile:


Hi Louis. Thanks a lot for this, but this code doesn’t work for me? I’m inserting it into ‘KEY’ at Dynamic, Wordpress and then one of the 'Shortcode’s.

Hi @boris,

You’ll want to place that code in your functions.php or use a code snippet plugin.
Then you simply use the shortcode name → today_date as the key.

1 Like

oh now i understand, thank you