Home › Forums › Add-ons › Repeater Field › Query repeater field with two values › Reply To: Query repeater field with two values
It is impossible to do a query based on two sub fields of a repeater where you want to get posts where sub field A == X
AND
sub field B == Y
, at least not in a single query. It would take several queries and a lot of php work. It’s the nature of how the sub fields are stored in the DB.
I have replied to several topics with an alternate means which makes repeater values easier to query. In this case I would save both values of each sub field into a single alternate meta field so that I could use that to query by. You can see examples of the basic idea here https://support.advancedcustomfields.com/forums/topic/query-last-row-of-a-repeater-field/ and here https://support.advancedcustomfields.com/forums/topic/sorting-admin-column-with-repeater/ and I’m sure there are others.
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.