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!
The ACF site is currently experiencing some issues.— Advanced Custom Fields (@wp_acf) September 21, 2022
We apologize for the inconvenience and we are working hard to get it back up and running as soon as possible.
© 2022 Advanced Custom Fields.