I am probably just overlooking something here, but some pointers would be greatly appreciated.
I am trying to create an event website using Wordpress and the Advanced Custom Fields plugin.
Now the events have two options, they are either One Day Events, or Multiple Day Events.
I have given them fields that the user can put the date in with the date picker.
One Day Event - one_day_event_date Multiple Day Event - event_start_date , event_end_date
(these output YYYYMMDD format: ie: 20140117)
My problem comes when I want to filter the results in the loop.
Ideally, I would like to show the events in date order, using the fields one_day_event_date and event_start_date.
But I want it to filter older events based on the values one_day_event_date and event_end_date
This is the code I have tried so far:
<?php
$currentdate = date("Ymd",mktime(0,0,0,date("m"),date("d")-1,date("Y")));
$args = array(
'post_type' => 'event',
'meta_query' => array(
array(
'key' => 'event_end_date',
'value' => $currentdate,
'compare' => '>',
'type' => 'DATE'
),
array(
'key' => 'one_day_event_date',
'value' => $currentdate,
'compare' => '>',
'type' => 'DATE'
)
),
'orderby' => 'meta_value_num',
'order' => 'ASC'
);
$query = new WP_Query( $args ); ?>
OR
relation to your meta query and just order by start date. also note that to order by a meta value, you have to set ameta_key
argument - seeWP_Query
in Codex.