Home › Forums › Add-ons › Repeater Field › Reverse Query Relationship subfield which is nested in a Repeater Field › Reply To: Reverse Query Relationship subfield which is nested in a Repeater Field
cinq75,
Have a look at my post about $wpdb. This might help you as well. Do something like this:
First, get all post ids of bands for a particular venue id, like:
global $wpdb;
$bands = $wpdb->get_results( "SELECT * FROM wp_postmeta WHERE meta_key LIKE 'venuerepeaterfieldname_%_band' AND meta_value = '{$venue_id}'", OBJECT );
The $bands object will contain the band post ids and also the row number which is the order in which it lies in the repeater field . The repeater row index is important information because you can use that to get all other fields in the same row of that repeater field.
For example, if you band added to the venue as the 3rd row of the repeater field, you will have that information in the $bands object array as “venuerepeaterfieldname_3_band”. You can then do something like:
$band_index_array = explode("_","venuerepeaterfieldname_3_band");
$band_index = $row_index_array[1]; //equal to 3
Then simply get all the values on that repeater row, using:
$bands = get_field('venuerepeaterfieldname', $venue_id);
$concerned_band = $bands[$band_index];
$concerned_band array will contain all fields that you may need. Hope that helps.
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.