Home › Forums › General Issues › display list of values from one field group › Reply To: display list of values from one field group
Hi @bispawel,
The important thing here is the repeater aspect, as opposed to the group itself. So within your post/page you’ll have a repeater that contains say 10 rows of data. It works a little bit like the WordPress loop. First, you check to see if there’s any data at all, then if there is data, you start a while loop to be able to access each repeater row individually.
Because these are sub_fields you need to use get_sub_field() or the_sub_field() to reference that data. In practice, it should look a little bit like this:
<?php
// check if the repeater field has rows of data
if( have_rows('kind_stuff') ):
?>
<table>
<?php
// loop through the rows of data
while ( have_rows('kind_stuff') ) : the_row();
// attribute sub fields to variables
$stuff_name = get_sub_field('name');
$stuff_cost = get_sub_field('cost');
$stuff_photo = get_sub_field('photo');
$stuff_link = get_sub_field('link');
?>
<tr>
<td><img src="<?php echo $stuff_photo['url']; ?>" alt="<?php echo $stuff_photo['alt']; ?>" /></td>
<td><?php echo $stuff_name; ?></td>
<td><?php echo "$" . $stuff_cost; ?></td>
<td><a href="<?php echo $stuff_link; ?>">View product</a></td>
</tr>
<?php endwhile; ?>
</table>
<?php
else :
// no rows found
endif;
?>
Depending on how you’ve set up each of those sub_fields will depend on specifically how you echo them out.
edit: The Repeater documentation page may help you further: https://www.advancedcustomfields.com/resources/repeater/
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.