Home › Forums › General Issues › get_posts, filtering by acf date field › Reply To: get_posts, filtering by acf date field
Thanks. Years after I had time to go back to this project.
WP_Query did the trick:
date_default_timezone_set("Europe/Zurich");
$dateNow = date('Y-m-d H:i:s');
$args = array(
'post_type' => 'veranstaltungen',
'post_status' => 'publish',
'order' => 'DESC',
'orderby' => 'meta_value',
'meta_query' => array(
array(
'key' => 'event_date',
'compare' => '>=',
'value' => $dateNow,
'type' => 'DATETIME',
),
),
'numberposts' => -1,
);
$query = new WP_Query($args);
$posts = $query->posts;
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.