Support

Account

Home Forums Add-ons Repeater Field Get single repeater row based on value Reply To: Get single repeater row based on value

  • Given the information you’ve provided, I’m still not sure I understand.

    If the value in $selection_key is a value in one of the sub fields of the repeater then there is no direct way to get that row. What you’d need to do is loop over the entire repeater and find the value.

    
    while (have_rows('repeater')) {
      the_row();
      if (get_sub_field('sub_field', 'options') == !$selection_key) {
        // not our row
        continue;
      }
      // will get here if this is our row
      $item = get_sub_field('item');
      
      $description = get_sub_field('description');
      
      $unit = get_sub_field('unit');
    
      $cost = get_sub_field('cost');
    }