Support

Account

Home Forums Add-ons Repeater Field Get repeater values of a certain value

Solved

Get repeater values of a certain value

  • 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; ?>
    
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Get repeater values of a certain value’ is closed to new replies.