Last active
April 10, 2019 15:09
-
-
Save johnkvang/f658c3845bef40e1427d1b12305820f4 to your computer and use it in GitHub Desktop.
Give an ACF Repeater subfield alternating classes, in this case, 'Odds' and 'Evens'. This can be applied to other things as well. Be creative. :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( have_rows( 'acf_repeater_field' ) ) : ?> | |
<?php $counter = 1 ; ?> | |
<?php while ( have_rows( 'acf_repeater_field' ) ) : the_row(); ?> | |
<?php | |
if ( 0 === $counter % 2 ) { | |
$class = 'even'; | |
} else { | |
$class = 'odd'; | |
} | |
?> | |
<div class="<?php echo $class;?>"> | |
<?php the_sub_field( 'acf_repeater_subfield' );?> | |
</div> | |
<?php $counter++ ; ?> | |
<?php endwhile; ?> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment