CailleachBhan
CailleachBhan

Reputation: 29

Show the two events closest to today in the future (ACF)

I want to display the two dates that are closest to the current date, but only if they're in the future. I'm using the ACF date-picker for this.

I'm not very good at php, so I'd appreciate if someone could point me in the right direction!

Upvotes: 0

Views: 693

Answers (1)

Hubert Popp
Hubert Popp

Reputation: 126

you could try something like:

$args = array(
   'post_type' => 'your_post_type',
   'posts_per_page' => 2,
   'meta_query' => array(
        'key'           => 'your_field_key',
        'compare'       => '>',
        'value'         => date('Y-m-d H:i:s'),
        'type'          => 'DATETIME'
   )
);

Hope that helps?

Upvotes: 1

Related Questions