Support

Account

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);
    ?>