Hello,
I am hoping someone will be able to help me… hopefully I will explain this well enough!
I want to use the repeater fields to display a block of content and images as a list. However, I don’t want to use one crop size for all images.
For example:
List item 1: Image size 1
List item 2: Image size 2
List item 3: Image size 2
List item 4: Image size 3
Is this even possible?
You’d be able to do this if you do an incrementing variable like:
<?php $i = 1; if( get_field('repeater') ): while( has_sub_field('repeater') ): ?>
<?php if ( $i == 1 ) { ?>
This is first list item
<?php } elseif ( $i == 2 ) { ?>
This is second list item
<?php } elseif ( $i == 3 ) { ?>
This is third list item
<?php } elseif ( $i == 4 ) { ?>
This is the fourth list item and so on...
<?php } ?>
<?php $i++; endwhile; endif; ?>
I wouldn’t duplicate the entire block of content that way but maybe like assign the image size to a variable and call it later or just do the $i conditional on the spot with the call to the image or similar. Hopefully that makes sense.