Home › Forums › General Issues › Radio Button Values
I’ve been searching forever for the code to display custom code depending on which radio button (custom field) value is selected, please help!
Hi,
This is how I did it:
if (get_field('field_name') == 'Field Value') {
// code to run if the above is true
} else if (get_field('other_field_name') == 'Other Field Value') {
// more code
}
If you still can’t get it, let me know here.
Hi I’ve been trying to get run a query from a repeater field with radio buttons in an option page. I’ve tried this code, but no joy:
<?php if(get_field('funders', 'option')): ?>
<?php if(get_sub_field('partner_type', 'option') == 'travel'): { ?>
<h4 class="section-header">Travel Partners</h4>
<?php while(has_sub_field('partner_type', 'option') == 'travel'): ?>
<?php the_sub_field('partner_name'); ?>
<?php endwhile; ?>
<?php } endif; ?>
<?php endif;?>
I’m not exactly sure how to run this query any hints are welcome.
Thanks
@ladygeekgeek
I needed a radio button choice of Vimeo Video or Image for a slider.
I did this:
<?php if(get_field('hero_slider_slide','option')): ?>
<ul class="slides">
<?php while(has_sub_field('hero_slider_slide','option')): ?>
<?php if (get_sub_field('hero_slider_video_or_image', 'option') == 'Vimeo Video') { ?>
<li>
<?php echo '<iframe id="player_1" src="http://player.vimeo.com/video/'. get_sub_field('hero_slider_vimeo_video','option') .'?api=1&player_id=player_1" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>' ?>
</li>
<?php } else if (get_sub_field('hero_slider_video_or_image', 'option') == 'Image') { ?>
<li>
<img alt="<?php echo $alt; ?>" src="<?php echo $image[0]; ?>" />
<div class="grid-container">
<div class="grid-100 tablet-grid-100 hero-caption">
<p class="tagline"><?php the_sub_field('hero_slider_slide_caption', 'option'); ?></p>
</div>
</div>
</li>
<?php } ?>
<?php endwhile; ?>
</ul>
<?php endif; ?>
The topic ‘Radio Button Values’ is closed to new replies.
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.