Support

Account

Home Forums Add-ons Repeater Field If repeater field has 1 rows, 2 rows etc Reply To: If repeater field has 1 rows, 2 rows etc

  • @neverything, thanks for your post. I used your example to make something for a project I’m working on, but all I needed to do was count number of field and apply different conditions. Here is my stripped down example below:

    <?php
    // get the count on the repeater field
    // mabye use get_sub_field() instead of get_field() if it's nested
    $count = count( get_sub_field( 'the_field' ) );
    
    // begin $count conditions
    if ( $count > 1 ) { ?>
      // greater than 1
      <?php the_field( 'great_than_1' ); ?>
    <?php } else { ?>
      // less than 1
      <?php the_field( 'less_than_1' ); ?>
    <?php } ?>

    https://gist.github.com/emaildano/6b6c47ec2bc3be54fcc6