Home › Forums › Add-ons › Repeater Field › Display repeater field base on radio button selected › Reply To: Display repeater field base on radio button selected
I think you would want to do something like this:
<?php if( have_rows('workshops') ): ?>
<?php while ( have_rows('workshops') ) : the_row();
// assigns checkbox value to var
$location = get_sub_field('checkbox'); ?>
<div id="boston">
<?php if ( $location == 'boston' || $location == 'both' ): ?>
// boston information
<?php get_sub_field('title'); ?>
<?php get_sub_field('link') ?>
<?php endif ?>
</div>
<div id="newton">
<?php if ( $location == 'newton' || $location == 'both' ): ?>
// newton information
<?php get_sub_field('title'); ?>
<?php get_sub_field('link') ?>
<?php endif ?>
</div>
<?php endwhile; ?>
<?php endif; ?>
Also you probably want your radio button choices to be flipped:
boston : Boston
newton : Newton
both : Both
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.