Home › Forums › General Issues › Group-field multiple choice button – behavior › Reply To: Group-field multiple choice button – behavior
In this case I would check for the value of the field that sets the condition for the field you want to display. That way even if there is a previous value saved in the database, the one you’d like to be currently displayed will still show up.
<article class="card">
<?php
// Variables.
$card = get_field( 'card' );
$button_type = get_field( 'card' )['button-type'];
?>
<?php if ( $button_type == 'file' ) { ?>
<a class="button" href="<?php echo $card['button-file']['url']; ?>"><?php echo $card['button-text']; ?></a>
<?php } elseif ( $button_type == 'email' ) { ?>
<a class="button" href="mailto:<?php echo $card['button-mail']; ?>"><?php echo $card['button-text']; ?></a>
<?php } else { ?>
<a class="button" href="<?php echo $card['button-url']; ?>"><?php echo $card['button-text']; ?></a>
<?php } ?>
</article>
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.