Home › Forums › Add-ons › Repeater Field › Repeater field with IF/ELSE based on sub_field value › Reply To: Repeater field with IF/ELSE based on sub_field value
I’ve checked the template files, one has a loop for a flexible content field. So, for case studies (basic blog post/category, not CPT) I have flexible content fields. I loop through just one of them (in the template include) and break after the first ‘paragraph’ content field… just to get the content for that case study.
If I remove that flexible content loop from the include.. the page LOADS but with only the first row of the repeater! IF I use get_posts instead of WP query, it loads all of the rows…
Here is the flexible content loop from the case-studies.php file:
<?php if (have_rows('flexible_content_types')): ?>
<?php while (have_rows('flexible_content_types')): the_row(); ?>
<?php if (get_row_layout() == 'paragraph_content'): ?>
<?php // get the FIRST paragraph content only, truncate it ?>
<p class="mb-3"><?php echo truncate(get_sub_field('content'), 180); ?></p>
<?php break; ?>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
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.