Support

Account

Home Forums Add-ons Repeater Field List All Sub Fields in a Repeater or Flex Field Reply To: List All Sub Fields in a Repeater or Flex Field

  • @trisham

    What you’re doing is not the same as what @chriscarvache is looking for tho.
    And fetching the repeater field into an array does work, I’ve done it many many times 🙂

    However I might have to explain it with a bit more code:

    
    <?php
    $repeater = get_field('repeaterfieldname');
    //make sure atleast 1 row exists
    if( $repeater ){
    	/* $repeater contains something like this, where each inner array represents a single row.
    	array(
    		[0] => array(
    			'subfield1' => 'value',
    			'subfield2' => 'value'
    		),
    		[1] => array(
    			'subfield1' => 'value',
    			'subfield2' => 'value'
    		),
    		[2] => array(
    			'subfield1' => 'value',
    			'subfield2' => 'value'
    		)
    	)
    	
    	
    	*/
    	foreach( $repeater as $row ){
    		//$row now contains all the subfields in this row of the repeater..
    		print_r($row);
    	}
    }	
    ?>