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’
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.