Home › Forums › General Issues › Conditionally Show Content Based on 'Choice' › Reply To: Conditionally Show Content Based on 'Choice'
Sorry about that; I think even I was confused on what I wanted to do…
The code below gave me what I wanted; I’m always open to tips on optimizing it further.
<?php if(get_field('choose_layout') == "1col")
{ ?>
<p><?php the_field('single_column'); ?></p>
<?php } elseif (get_field('choose_layout') == "2col")
{ ?>
<p><?php the_field('two_columns_left'); ?></p>
<p><?php the_field('two_columns_right'); ?></p>
<?php } elseif (get_field('choose_layout') == "3col")
{ ?>
<p><?php the_field('three_columns_left'); ?></p>
<p><?php the_field('three_columns_middle'); ?></p>
<p><?php the_field('three_columns_right'); ?></p>
<?php } ?>
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.