Support

Account

Home Forums Add-ons Repeater Field Add element to first item/row in Repeater Field

Solved

Add element to first item/row in Repeater Field

  • Hi,

    I have built a form with the repeater field, but I don’t know how to add element checked=”checked” to only first item in the loop?

    <?php if( have_rows('repeater_field_name') ): ?>
    
    <form>
      <?php while ( have_rows('repeater_field_name') ) : the_row(); ?>
      
      <!-- first item/row -->
      <input type="radio" checked="checked">
      <label><?php the_sub_field('sub_field_name'); ?></label>
      
      <!-- next items/rows -->
      <input type="radio">
      <label><?php the_sub_field('sub_field_name'); ?></label>
      
      <input type="radio">
      <label><?php the_sub_field('sub_field_name'); ?></label>
      
      etc.
      
      <?php endwhile; ?>
    </form>
    <?php endif;  ?>

    Many thanks

Viewing 1 post (of 1 total)

The topic ‘Add element to first item/row in Repeater Field’ is closed to new replies.