Home › Forums › Add-ons › Flexible Content Field › Post Based On Condition of Field › Reply To: Post Based On Condition of Field
This seems to work, but it seem rather redundant:
<article id="blue" <?php post_class(); ?>>
<?php
if( have_rows('text_section') ):
while ( have_rows('text_section') ) : the_row();
$title = get_sub_field('title');
$text = get_sub_field('text');
$texts = get_sub_field('text_copy');
$cols = get_sub_field('columns');
?>
<div class="container">
<?php
if(get_sub_field('columns') == "1") : ?>
<div class="entry-header">
<h1 class="entry-title"><?php the_sub_field('title'); ?></h1>
</div>
<?php the_sub_field('text'); ?>
<?php elseif( get_sub_field('columns') == "2") : ?>
<div class="entry-header">
<h1 class="entry-title"><?php the_sub_field('title'); ?></h1>
</div>
<div class="col-sm-6">
<?php the_sub_field('text'); ?>
</div>
<div class="col-sm-6">
<?php the_sub_field('text_copy'); ?>
</div>
<?php endif;
endwhile;
endif;
?>
</div>
</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.