Home › Forums › Add-ons › Flexible Content Field › Check if end of loop or next row layout's name › Reply To: Check if end of loop or next row layout's name
$layouts = get_field('field_name', false, false);
$count = 0;
while (have_rows('flex_field')) {
the_row();
// normal code for displaying your layout here
if ($count == count($layouts)) {
// end of layouts reached
// do end of loop code
}
if (isset($layouts[$count+1])) {
if ($layout[$count+1] == 'Layout B') {
// next layout is layout be
// do that code
}
}
// increment count
$count++;
} // end while have rows
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.