Support

Account

Home Forums Front-end Issues Conditional display according to radio button

Solved

Conditional display according to radio button

  • Hi,
    I’ve set a radio button field to ‘no : No’ and ‘yes : Yes’ to display different messages. In the page, I set hereafter code :
    <?php if( get_field('status') == 'No' ): ?> <div class="side-button"> <a href="<?php the_field('the_link', get_the_ID()) ?>" target="_blank">Click the link</a> </div> <?php endif; ?> <?php if( get_field('status') == 'Yes' ): ?> <div class="side-button-dark"> Special message </div> <?php endif; ?>
    But problem is nothing displays. With just
    <p><?php the_field('status'); ?></p>
    it correctly displays ‘no,No’ and ‘yes,Yes’. I also tried <?php if( get_field('status') == 'no' ): ?> (ie field value and no label) but it doesn’t change anything. I’m sure I’m missing a stupid little thing, but I can’t figure out what. Any help would be welcome.

  • Sorry, I found myself what was silly :-S It’s often while asking something that you found the solution, which is obvioulsly :

    <?php if( get_field('status') == 'no'): ?>
    													<div class="side-button">
    														<a href="<?php the_field('the_link', get_the_ID()) ?>" target="_blank">Click the link</a>
    													</div>
    												<?php elseif	( get_field('status') == 'yes' ): ?>
    													<div class="side-button-dark">
    														Special message
    													</div>
    												<?php endif; ?>

    Sorry, but I don’t find where to delete thread…

  • Thank you for posing your solution, this really helped me out!

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

The topic ‘Conditional display according to radio button’ is closed to new replies.