Home › Forums › Add-ons › Repeater Field › Can't get repeater in group field to return true with have_rows() › Reply To: Can't get repeater in group field to return true with have_rows()
Hi there,
Could you please try something like this :
<?php
$group = get_field('group_field');
$heading = $group['heading'];
$text = $group['text'];
$repeater = $group['links_list']; //
?>
<h3><?php echo $heading; ?></h3>
<?php echo $text; ?>
<?php if( have_rows($repeater) ) : ?>
<ul class="links-list">
<?php while( have_rows($repeater) ) : the_row(); $link = get_sub_field('link'); ?>
<li><a href="<?php echo $link['url']; ?>" target="<?php echo $link['target']; ?>"><?php echo $link['title']; ?></a></li>
<?php endwhile; ?>
</ul>
<?php endif;?>
Explanation
As a repeater field, the group field is a row of datas, but it contains a single row.
(as it’s explained in the documentation: https://www.advancedcustomfields.com/resources/group/)
In your code, you tried to have the repeater fields datas, without indicating in which $row your repeater field is (your group field).
Let me know if it helps.
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.