Support

Account

Home Forums Add-ons Repeater Field Flexible Content & Repeater Content Showing

Helping

Flexible Content & Repeater Content Showing

  • Okay, I have a flexible content container inside a repeater field. I have the flexible content showing alright. However, is there any way that I can get the other fields within the repeater field to show? Other than those inside the flexible content.

    Here’s what I’m using:

            <?php
            if (have_rows('home_points')) {
                while (have_rows('home_points')) {
                    the_row();
                    if (have_rows('point_column')) {
                        while (have_rows('point_column')) {
                            the_row();
                            $layout = get_row_layout();
    
                            if ($layout == 'column_header') {
    
                                the_sub_field('column_head');
                            } elseif ($layout == 'column_row') {
    
                                the_sub_field('another_row');
                            }
    
                            the_sub_field('brand_1'); //this is the repeater subfield I want to show
                        }
                    }
    
                    //I also tried putting the repeater subfield here.
                }
            }
            ?>
  • 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"
      }
    }
    ?>
    
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Flexible Content & Repeater Content Showing’ is closed to new replies.