Support

Account

Home Forums Add-ons Repeater Field Help Updating v3 repeater code to v4

Unread

Help Updating v3 repeater code to v4

  • Hi, this repeater code from v3 is not working in v4. Wondering if someone could take a look and let me know what is up?

    Old v3 code:

    <?php  while(the_repeater_field('my-repeater')): ?>
    <?php  $checkIfEmpty = get_sub_field('link'); ?>
    <?php  endwhile; ?>
    <?php  if ($checkIfEmpty != '') { ?>
    <div>
      <ul>
        <?php  while(the_repeater_field('my-repeater')): ?>
          <li>
              <a href="<?php  the_sub_field('link'); ?>">
                <?php  the_sub_field('title'); ?>
              </a>
              <span><?php  the_sub_field('description'); ?></span>
          </li>
        <?php  endwhile; ?>
      </ul>
    </div>
    <?php  } ?>

    My attempt at updating to v4 code:

    <?php if( have_rows('my-repeater') ): ?>
    <div>
      <ul>
        <?php while( have_rows('my-repeater') ): the_row(); 
            $link = get_sub_field('link');
            ?>
            <li>
                <a href="<?php  the_sub_field('link'); ?>"><?php  the_sub_field('title'); ?></a> <span><?php  the_sub_field('description'); ?></span>
            </li>
        <?php endwhile; ?>
        </ul>
    </div>
    <?php endif; ?>
Viewing 1 post (of 1 total)

The topic ‘Help Updating v3 repeater code to v4’ is closed to new replies.