Support

Account

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.