Home › Forums › General Issues › AND relation with repeater values in query › Reply To: AND relation with repeater values in query
The problem is not with the query, the problem is with the field names. A query that searches repeaters and also matches rows on a repeater is impossible.
The meta names of repeaters are "{$repeater_name}_{$row_index}_{$sub_field_name}"
The documentation and function/filter you are using causes the query to ignore the {$row_index}
so if any row has a matching value in the first sub field and any other row has a matching value in the other sub field then the post will match.
The only work around that I have ever found is to use an acf/save_post action to get the values of the repeater and I store a multidimensional array in a WP option. Each element of the array is associated with the post. then I search the multidimensional array to locate the post IDs that need to be retrieved.
$option = array(
// nested array for each post
$post_id => array(
// nested array of values for each row of the repeater
array(
// field name => value pairs for each row
'field_name_1' => 'value_1',
'field_name_2' => 'value_2'
)
)
)
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.