Home › Forums › Add-ons › Repeater Field › Query repeater field with two values › Reply To: Query repeater field with two values
To do this with queries on the existing fields you would need to
1) use $wpdb to query the post meta table to get all of the rows where
{$repeater_name}\_%\_{$sub_field_name_1} == "X"
2) Then you’d need to loop though the results of this query, get the post value and the meta key and then you’d need to do another query where
{$repeater_name}\_{$index_from_first_query}\_{$sub_field_name_2} == "Y"
3) From this you can construct a list of post ID and use that list in for the post__in
argument of a WP_Query.
It really is much easier to use an acf/save_post filter to convert the values into something that can be more easily searched.
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.