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>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
Are you building WordPress sites with ACF and @BeaverBuilder, and wanted to use your ACF Blocks in both the block editor and Beaver Builder?
— Advanced Custom Fields (@wp_acf) May 10, 2023
The BB team recently added support for using ACF Blocks in Beaver Builder. Check it out 👇https://t.co/UalEIa5aQi
© 2023 Advanced Custom Fields.
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.