Home › Forums › General Issues › display list of values from one field group › Reply To: display list of values from one field group
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’re hard at work on ACF 6.1, and Beta 1 is now available 🚀— Advanced Custom Fields (@wp_acf) March 16, 2023
This release includes custom post type and taxonomy registration, an improved experience when selecting field types, PHP 8.1 and 8.2 compatibility, and more!
Let’s take a look 🧵https://t.co/Y0WcAT11l4
© 2023 Advanced Custom Fields.