Home › Forums › Add-ons › Flexible Content Field › count get_row_layout to add odd / even class › Reply To: count get_row_layout to add odd / even class
Because you have different types of layouts the solution would be to keep a running total of each type of layout.
$layout_counts = array();
// ... some time later
while (have_rows('staff_content')) {
the_row();
$layout = get_row_layout();
if (!isset($layout_counts[$layout])) {
$layout_counts[$layout] = 0;
}
$layout_counts[$layout]++;
$class = 'even';
if ($layout_counts[$layout] % 2) {
$class = 'odd';
}
//... some time later
if ($layout == 'staff_member') {
?>
<div class="staff <?php echo $class; ?>">
/// etc...
</div>
<?php
}
}
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.