Home › Forums › Add-ons › Repeater Field › How do I query a repeater which uses recurring dates? › Reply To: How do I query a repeater which uses recurring dates?
I have been testing with the following events and dates…
Test 1
23/05/2015 – 23/05/2015
25/05/2015 – 29/05/2015
Test 2
24/05/2015 – 24/05/2015
The trouble is that the following code is returning Test 1 and Test 2 for the date range of 24/05/2015 – 24/05/2015 when only Test 2 should be returned
<?php
// filter
function my_posts_where( $where ) {
$where = str_replace("meta_key = 'event_dates_%", "meta_key LIKE 'event_dates_%", $where);
return $where;
}
add_filter('posts_where', 'my_posts_where');
$args = array (
'post_type' => 'event',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'event_dates_%_start_date',
'compare' => '<=',
'value' => '20150524',
),
array(
'key' => 'event_dates_%_end_date',
'compare' => '>=',
'value' => '20150524',
)
),
);
$the_query = new WP_Query( $args );
?>
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.