Reputation: 3
I'm trying to order a list of events by closest date to the user. I am using a datetime picker using the Advanced Custom Fields plugin.
But, the events seem to be rendering by the post date instead of the custom datetime picker I have created.
This is a Wordpress Application that is using Timber for the templating engine.
$context['events'] = Timber::get_posts(
array(
'post_type' => 'event',
'order' => 'ASC',
'order_by' => 'date_and_time_of_event',
)
);
The expected result is that the page renders the events list by the date_and_time_of_event
and shows the date nearest to the user first.
But I think that the events list is rendering using the post_date
instead of the required date_and_time_of_event
.
Upvotes: 0
Views: 150
Reputation: 131
array(
'post_type' => 'event',
'meta_key' => 'date_and_time_of_event',
'orderby' => 'meta_value',
'order' => 'ASC',
)
Try this
Upvotes: 1