I have the following code:-
<?php if( have_rows('local_amenities', $development_page) ): ?>
<?php while( have_rows('local_amenities', $development_page) ): the_row(); // loop through rows (parent repeater) ?>
<p><?php the_sub_field('amenity_name'); ?></p>
<p><?php the_sub_field('amenity_address'); ?></p>
<p><?php the_sub_field('type_of_amenity'); ?></p>
<?php endwhile; ?>
<?php endif; ?>
What I want to do is only get the above values where the_sub_field('type_of_amenity') == 'Example'
How would I do this?
Managed to do this in the end with the below code:-
<?php if( have_rows('local_amenities', $development_page) ): ?>
<?php while( have_rows('local_amenities', $development_page) ): the_row(); // loop through rows (parent repeater) ?>
<?php if (get_sub_field('type_of_amenity') == 'supermarkets') { ?>
<p><?php the_sub_field('amenity_name'); ?></p>
<p><?php the_sub_field('amenity_address'); ?></p>
<p><?php the_sub_field('type_of_amenity'); ?></p>
<?php } ?>
<?php endwhile; ?>
<?php endif; ?>