Support

Account

Home Forums Add-ons Repeater Field Selecting a nested repeater field value without looping.

Solved

Selecting a nested repeater field value without looping.

  • Hi all!
    How can I select a nested repeater field value without the loop?
    Like:

    <?php
    
    $rows = get_field('main_repeater_field_name');
    
    $one = $rows[0]['nested_repeater_field_name'][0]['sub_field_name']; 
    
    ?>

    Is this even possible?

    I need to add it into my custom for-loop:

    <?php
    
    //populate the groupA,B,C... array with the teams
    $teamName = get_sub_field('sub_field_name');
    
    for($i=1; $i<=$nrOfTeams; $i++){
    	
    	${"group$groupLetter"}[$i] = $teamName[$i];
    
    }
    
    ?>
    

    Thanks for any insights!

  • I found it 🙂

    <?php
    
    $one = $rows[0]['nested_repeater_field_name'][0]['sub_field_name']; 
    
    ?>

    Somehow I added the answer in the question.
    Just make sure each value is an array when going deeper in the array.

    $one = $rows[array][array][array]['sub_field_name']

    Peace out!

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Selecting a nested repeater field value without looping.’ is closed to new replies.