I’m starting with WordPress, already achieved some queries, but this one… ugh! It’s being a pain to me!
What i want to do is this part of query:
" ... WHERE "VALUE_THAT_I_WANT" BETWEEN event_start_date AND event_end_date ..."
Where “event_start_date” and “event_end_date” are meta keys ( i want to use their values, not mine!)
This is what i had so far..
$tEA = array(
'post_type' => 'event',
'meta_key' => $metaKey,
'orderby' => 'meta_value',
'order' => $order,
'posts_per_page' => $postPerPage,
'meta_query' => array(
array(
'key' => $metaKey,
'value' => $today,
'compare' => "=",
'type' => 'DATE'
),
array(
'key' => '_event_end_time'
)
)
);
This should work for you:
Note that START_DATE and END_DATE should be in MySQL date format
YYYY-MM-DD
Didn’t test it, but what about this?
I am not sure if you needed the other compare, if you do, just prepend it 😛
Since WP 3.7 you can pass ‘date_query’ as an argument.
Example that returns posts from January 1st to February 28th:
Code taken from https://codex.wordpress.org/Class_Reference/WP_Query