Home › Forums › Add-ons › Repeater Field › Insert something into the repeater loop? › Reply To: Insert something into the repeater loop?
Hi @kyon147
Sure there is. Let’s assume that you’re using have_rows for looping out your repeater. Here’s an example of how you could do it:
<?php
if( have_rows('repeater') ){
$i = 1;
while( have_rows('repeater') ){
the_row();
//stuff
the_sub_field('subfield');
//advert after every third row
if( $i % 3 == 0 ){
//advert code
}
$i++;
}
}
?>
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!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.