Support

Account

Home Forums Add-ons Flexible Content Field Post Based On Condition of Field Reply To: Post Based On Condition of Field

  • Based on the code and the ACF field setup in your other post, this should work for you:

    <?php
    $title	= get_sub_field('title');
    $text	= get_sub_field('text');
    $texts	= get_sub_field('text_copy');
    $cols	= get_sub_field('columns');
    
    <?php
    // check if the flexible content field has rows of data
    if( have_rows('text_section') ):
    	while ( have_rows('text_section') ) : the_row();
    
    		if( get_row_layout() == 'blue_content_blocks' ) :
    
    			if( $cols == "1") : ?>
    				<div>
    					<?php echo $title; ?>
    					<?php echo $text; ?>
    				</div>
    			<?php elseif( $cols == "2") : ?>
    					<div class="col-sm-6">
    						<?php echo $title; ?>
    						<?php echo $texts; ?>
    					</div>
    			<?php endif;
    
    		endif; //get_row_layout
    
    	endwhile; //have_rows
    
    endif; //have_rows
    
    ?>

    Edit: variable name typo