Support

Account

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