Home › Forums › General Issues › Query posts after "today" using ACF Date › Reply To: Query posts after "today" using ACF Date
Hello, I found this post but it doesn’t work for me. I have custom posts with an ACF date field “event_date”. I post a whole month’s worth of these, but I only want to show the ones with event_date after today (to not show ones that happened already).
I am using ACF 5.8.7 (not pro).
My query follows, it shows all events even ones in the past:
<?php
// $today = new DateTime(date('Y-m-d'));
$today = date('Ymd');
$start_date = date('Ym01');
$end_date = date('Ymt');
$meta_query = array(
'key' => 'event_date',
'value' => $today,
'type' => 'numeric',
'compare' => '>',
);?>
<?php
$args = array(
'post_type' => 'hh_event',
'posts_per_page' => -1,
'orderby' => 'meta_value',
'meta_key' => 'event_date',
'order' => 'ASC',
);
$the_query = new WP_Query($args);
?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.