Home › Forums › General Issues › Repeater field dumping into tables › Reply To: Repeater field dumping into tables
I wasn’t exactly sure what $totalNum is used for but this is an example that will add the class every other row, starting with the second
<table>
<tbody>
<tr>
<th>Cookie Flavors</th>
</tr>
<?php
if (get_field('flavors')) {
$index = 1;
while (has_sub_field('flavors')) {
?>
<tr<?php
if ($index % 2 != 0) {
?> class="bg"<?php
}
?> class="bg">
<td><?php the_sub_field('flavor'); ?></td>
</tr>
<?php
$index++;
} // end while
} // end if
?>
</tbody>
</table>
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.