I need to query two custom post types,
like this:
'post_type' => array ('single_events', 'group_of_events'),
and i need to select certain posts in a certain order, to do this i wrote a meta query to select posts between two dates stored in a custom field.
my problem is now: for my first custom post type this works well, these posts only have the field for start-date.
but for my second custom post type i need to use another key for the meta_query, because these posts are events with an start-date and an end-date,
so my question is how is it possible to modify the meta query to select the posts
for single_events
by meta_key =>'start_date'
and for group_of_events
by meta_key =>'end_date'
at the moment it looks like this:
'meta_query' => array(
'relation' => 'AND',
'time' => array(
'key' => 'start_date', /// or 'end_date' for cpt 'group_of_events??
'compare' => 'BETWEEN',
'type' => 'DATE',
'value' => array($filter_start_date, $filter_end_date),
),
'type' => array(
'key' => 'type',
'compare' => 'IN',
'value' => $filter_type,
),
),
'orderby' => 'time',
i probably could give the single_events also an enddate just by cloning the start_date but maybe there is a more elegant way to do this?
thanks alot!