Support

Account

Home › Forums › Add-ons › Flexible Content Field › How to determine the number of rows that will render in flexible content

Solved

How to determine the number of rows that will render in flexible content

  • I’d like to control the styles for the container holding the flexible content layouts so I need to determine how many layouts the user has added. How can this be accomplished?

  • Got it! This just happens to be a nested flexible content field.

    <?php if (get_row_layout() == 'flexibl_content_field') :
        $layouts = get_sub_field('sub_flexible_content_field');
        $layoutsCount = count($layouts);
    ?>

    and use it like this in the while loop
    <div class="col-md-6 <?php echo $layoutsCount == 3 ? 'col-lg-4' : 'col-lg-6'; ?>

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.