Support

Account

Home Forums Add-ons Repeater Field Flexible Content & Repeater Content Showing Reply To: Flexible Content & Repeater Content Showing

  • You can’t get values from the repeater inside of the loop for the nested repeater.

    the_row() will actually return an array of the current row

    
    <?php
    if (have_rows('home_points')) {
      while (have_rows('home_points')) {
        
        // this will return the current repeater row in an array
        $repeater_row = the_row();
        
        // any call to the_sub_field() or get_sub_field()
        // here should get sub fields of the repeater "home_points"
        
        if (have_rows('point_column')) {
          while (have_rows('point_column')) {
            the_row();
            
            // you cannot get fields from the repeater inside of the
            // loop that is getting values from the nested repeater
            
            $layout = get_row_layout();
            
            if ($layout == 'column_header') {
            
                the_sub_field('column_head');
            } elseif ($layout == 'column_row') {
            
                the_sub_field('another_row');
            }
            
            
            // use the array $repeater_row to access parent repeater row values
            echo $repeater_row['brand_1'];
    
          }
        }
        
        // any call to the_sub_field() or get_sub_field()
        // here should get subfields of the repeater "home_points"
      }
    }
    ?>