I am trying to pull a list of events that are upcoming in WordPress using the ACF DateTime picker field.
What I thought should be a relatively simple set of $args
is now baffling me as to why it does not work:
$args = [
"post_type" => "event",
"post_status" => "publish",
"posts_per_page" => 3,
"order" => "ASC",
"orderby" => "meta_value",
"cat" => implode(',', $category),
"meta_query" => [
[
"key" => "event_start_date_and_time",
"compare" => ">=",
"value" => date('U'),
"type" => "DATETIME"
]
],
"meta_key" => "event_start_date_and_time",
"meta_type" => "DATE"
];
This is bringing through events but they are not all in ASC order of the start date time.
Am I missing something obvious?
Documentationhttps://www.advancedcustomfields.com/resources/date-time-picker/
Database valuesACF DateTime Picker fields will store dates in the database like the following
2018-07-21 15:00:00