Support

Account

Home Forums General Issues Radio Button Values

Solved

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.

  • Thank you @smspaul I have been racking my brain on this!

  • 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; ?>
  • Thanks – I’ll give that a go next time.

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Radio Button Values’ is closed to new replies.