Support

Account

Home Forums ACF PRO A group inside a repeater inside a group inside a repeater Reply To: A group inside a repeater inside a group inside a repeater

  • You cannot mix get_sub_field() and have_rows().

    
    $group_parent = get_sub_field('group_parent');
    

    gets an array, including the repeater sub field and its sub fields.
    Once you do this then you cannot use have_rows() on the sub fields of this field because you are already inside a have_rows() loop for ‘group_parent’

    basically you either need to loop over the array returned without using have_rows() or you always need to use have_rows(). You cannot loop over a sub fields that is a repeater or a group without looping over the parent repeater or group.

    
    // have rows
    while( have_rows('parent_gallery') ) ....
      while (have_rows('group_parent')) .....
        while( have_rows('children_galleries') ) .....
    
    
    // using the array, I'm not real sure about this but hopefully you get the idea
    while( have_rows('parent_gallery') ) : the_row();
      $group_parent = get_sub_field('group_parent');
        ....
          $children_galleries = $group_parent['children_galleries'];
          foreach ($children_galleries as $gallery)
    

    at any rate, if you output the array you’ll see what you’re working with

    
    $group_parent = get_sub_field('group_parent');
    echo '<pre>'; print_r($group_parent); echo '</pre>';
    

    at each nested level you have a choice, get the sub fields contents or use another have_rows() loop. If you get the sub field values then from that point on you must use the array that is returned and you can no longer use have_rows() for any of its sub fields that are repeaters or groups.