Home › Forums › General Issues › Using datepicker field in a WP_Query Date Query › Reply To: Using datepicker field in a WP_Query Date Query
Well that turned out to be fairly easy. Here’s the code, hope it helps someone:
To get items that have a date set in the future, make this WP_Query, where event_start_date is your custom field.
$meta_query = array(
array(
'key' => 'event_start_date',
'value' => date('Ymd'),
'type' => 'DATE',
'compare' => '>='
)
);
$args = array(
'post_type' => 'post',
'posts_per_page' => $posts_per_page,
'order' => 'DESC',
'orderby' => 'meta_value_num',
'meta_key' => 'event_start_date',
'offset' => (max(1, get_query_var('paged')) - 1) * $posts_per_page,
'meta_query' => $meta_query
);
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.