Support

Account

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

Unread

Help Updating v3 repeater code to v4

    • wyclef

    • November 27, 2019 at 12:16 am

    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)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.