Home › Forums › Add-ons › Flexible Content Field › Post Based On Condition of Field › Reply To: Post Based On Condition of Field
Flexible Content works in much the same way as a repeater field, where you can check to see if there’s anything in it, and then reference all of the sub_fields within (note: sub_field).
In your case, once you’ve performed your initial check for existence, grab the select sub_field and check if there should be one or two columns:
<?php if(get_sub_field('columns_required') == "one_column") : ?>
<div class="column wide">
<?php the_sub_field('column_content'); ?>
</div>
<?php elseif( get_sub_field('columns_required') == "two_columns") : ?>
<div class="column half_size">
<?php the_sub_field('left_column'); ?>
</div>
<div class="column half_size">
<?php the_sub_field('right_column'); ?>
</div>
<?php endif; ?>
Hope that helps
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.