Home › Forums › General Issues › Query between dates using Date Picker fields › Reply To: Query between dates using Date Picker fields
OMG what a pain. I got it!
so use their tutorial on comparing dates but instead of date(‘Ymd’) use current_time
$today = current_time('Ymd');
$args = array (
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'start_date',
'compare' => '<=',
'value' => $today,
),
array(
'key' => 'end_date',
'compare' => '>=',
'value' => $today,
)
),
);
I removed all that stuff in the functions.php and just did
$event1 = current_time(‘Ymd’) then for my array I used a key of my end date field compare to greater than $event1 (aka current date in Ymd).
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.