Support

Account

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.