WordPress Meta Query Mix Relation
Using a mix of 'And' and 'Or' operators in the meta_query portion of wordpress get posts query. Specifically with this one, I was looking for an event that had a tag specified by the $show variable, and where the date to see if it was current was either the start or end date of the event (the start date was the only required field in the admin side, so some events don't have end dates).
$args['meta_query'] = array(
'relation' => 'AND',
array(
'key' => 'tags',
'value' => '"'.$show.'"',
'compare' => 'LIKE',
),
array(
'relation' => 'OR',
array(
'key' => 'event_date_end',
'value' => date("Ymd000000"),
'compare' => '>='
),
array(
'key' => 'event_date',
'value' => date("Ymd000000"),
'compare' => '>='
)
)
);
-
Adventure
-
The Built Environment
-
Locations
-
Web Dev