stevemcilwaine
6/26/2019 - 3:08 PM

ACF Looping through a flex content

Uses an ACF function to loop through a flex content container with the name _content. It checks through each row (should only be the one), and allows access to properties within - eg fields and sub_fields.

<?php 
    if (have_rows('_content')):
    while (have_rows('_content')) : the_row();
    if (get_sub_field('minutes_to_read_required')) : ?>
        <div class="insights-listing__read-time-inner">
            <svg class="insights-listing__read-time-clock">
                <use xlink:href="#sprite-clock"></use>
            </svg>
            <p class="insights-listing__read-time-title">
                <?php echo get_sub_field('minutes_to_read'); ?> Minute Read
            </p>
        </div>
<?php
    endif;
    endwhile;
    endif;
?>