1

I have a Repeater [Layout] inside a Group [Layout] and I’m trying to display the value of a sub field Text [Basic] from a child of the Group [Layout] but it returns me nothing. It’s empty when I’m making a condition to make sure if the Repeater [Layout] is True. I want to display the Group Name (Text [Basic]) when Add File Repeater [Layout] is True. Please check my ACF Structure below.

ACF Structure

  • Marketing Group [Layout] (name: marketing)
  • -- Group Name Text [Basic] (name: group_name)
  • --- Add File Repeater [Layout] (name: add_file)

This code is correct, I can see my group_name value

<!-- Group [Layout] -->
<?php if (have_rows('marketing')): ?>
  <?php while (have_rows('marketing')): the_row(); ?>

    <?php
      /*--------------
      Extract ACF sub fields
      --------------*/

      // Text [Basic]
      $group_name = get_sub_field('group_name');
    ?>
    <li><?php the_sub_field('group_name');  ?></li>

  <?php endwhile; ?>
<?php endif; ?> <!-- End of Group [Layout] -->

But when I add the condition here, I cannot access to the value of the_sub_field('group_name'); anymore en the repeater layout add_file is true, it's empty

<!-- Group [Layout] -->
<?php if (have_rows('marketing')): ?>
  <?php while (have_rows('marketing')): the_row(); ?>

    <?php
      /*--------------
      Extract ACF sub fields
      --------------*/

      // Text [Basic]
      $group_name = get_sub_field('group_name');
    ?>
    <?php if (have_rows('add_file')): ?>
      <li><?php the_sub_field('group_name');  ?></li>
    <?php endif; ?>

  <?php endwhile; ?>
<?php endif; ?> <!-- End of Group [Layout] -->

Thank you! I cannot find the answer in the official ACF Documentation...

  • Would you be able to post the exported JSON for your field? That might help folks troubleshoot this in a live environment. See https://www.utilizewp.com/export-import-acf-field-group/ for assistance with export. – Greg Burkett Oct 11 '22 at 17:36

0 Answers0