Support

Account

Home Forums Add-ons Repeater Field how to list name of subfields in a row Reply To: how to list name of subfields in a row

  • thanks for your help. I still don’t understand it. I tried removing the while loop and using your solution and I’m able to print all the keys and value but onyl from the first row of the array:

    if($check['type'] == 'repeater'):
    									if( have_rows($name) ):
    											$values = get_field_object($name)? : [];
    											foreach ($values as $key => $value) {
           											$content .= "key: $key - value: $value </br>";
       											 }
    									endif;
    								elseif($check['type'] == 'wysiwyg'):
    									$content .= $value;
    								else:
    
    								endif;

    and what I’m actually trying to exactly do is this:

    if( have_rows($name) ):
    										
    										while ( have_rows($name) ) : the_row();
    										
    											// write method to print subfields without knowing their names.
    											$content .= get_sub_field('effect_name') . "</br>";
    											$content .= get_sub_field('effect_magnitude') . "</br>";
    											$content .= get_sub_field('effect_description') . "</br>";
    
    										endwhile;
    									endif;

    but without knowing the names ‘effect_name’, ‘effect_magnitude’ and ‘effect_description’