Support

Account

Home Forums General Issues WP_Query for upcoming events via ACF date field

Unread

WP_Query for upcoming events via ACF date field

  • Hey, I know that this has been asked before, but I’ve been banging my head against it to no avail for hours now. I’m working on this client site and on the homepage I’m trying to display only the upcoming races.

    Here is the code that I have, which still shows a completed race…

    $today = current_time('Ymd');
    $date_args = array(
    	'post_type' => 'race',
    	'posts_per_page' => 3,
        'showposts' => 3,
    	'meta_key'  => 'race_date',
    	'orderby'   => 'meta_value_num',
    	'order'     => 'ASC',
        'meta-query' => array(
            array(
                'key' => 'race_date',
                'type' => 'NUMBER',
                'compare' => '>=',
                'value' => $today,)
        ),
    );
    
    $date_query = new WP_Query( $date_args );

    On my local version of the site I’ve output the race_date and $today values, and it looks to me like the comparison should be working (see image below). I’m sure I’m missing something simple, but someone please tell me what it is.

    //edit: Link to image since it’s not displaying.

    Local homepage with date output shown

Viewing 1 post (of 1 total)

The topic ‘WP_Query for upcoming events via ACF date field’ is closed to new replies.