Support

Account

Home Forums Add-ons Repeater Field Insert div after 2nd row of ACF repeater Reply To: Insert div after 2nd row of ACF repeater

  • 
    <div class="article-container">
      <?php 
        if( have_rows('news_article') ):
          // add counter
          $count = 0;
          while( have_rows('news_article') ): the_row(); 
    
            // vars
            $title = get_sub_field('article_title');
            $url = get_sub_field('source_link');
            $source = get_sub_field('source_link_text');
            $date = get_sub_field('article_date');
            $quote= get_sub_field('article_pull_quote');
            $text= get_sub_field('article_description');
            $link= get_sub_field('article_link');
    
            ?>
          
              <div class="article-block">
                <h4><?php echo $title; ?></h4>
                <p><a href="<?php echo $url; ?>" target="_blank"><?php echo $source; ?></a> - <?php echo $date; ?></p>
                <div class="pull-quote"><p><?php echo $quote; ?></p></div>
                <img src="/../wp-content/uploads/2017/03/3plus.svg" class="plus-border">
                <p><?php echo $text; ?></p>
                <a href="<?php echo $link; ?>" target="_blank">Read the full story</a>
              </div>
            <?php 
            // increment counter and see if 2 rows have been shown
            $counter++;
            if ($counter == 2) {
              // yes, show something else
              ?>
                <div class="quote-block">
                  <div class="quote-block-inner">
                    <h5><?php the_field('news_feature_quote'); ?></h5>
                    <p><?php the_field('news_quote_author'); ?></p>
                  </div>
                </div>
              <?php 
            }
          endwhile;
        endif;
      ?>
    </div>