Php WordPress中的高级自定义字段-无法在组中使用转发器

Php WordPress中的高级自定义字段-无法在组中使用转发器,php,wordpress,grouping,advanced-custom-fields,repeater,Php,Wordpress,Grouping,Advanced Custom Fields,Repeater,我以前做过20多次,但我不明白为什么我对repeater字段的调用会破坏我的站点 由于php错误,页面无法加载,如果我删除调用repeater字段的while循环,页面就会工作 我想知道在这个片段中我做错了什么: ~repeater字段称为application_sectors,可能是开始寻找修复的好地方 <?php $has_applications_of_ebflow = get_field('has_applications_of_ebflow'); ?> <?php

我以前做过20多次,但我不明白为什么我对repeater字段的调用会破坏我的站点

由于php错误,页面无法加载,如果我删除调用repeater字段的while循环,页面就会工作

我想知道在这个片段中我做错了什么:

~repeater字段称为application_sectors,可能是开始寻找修复的好地方

<?php
$has_applications_of_ebflow = get_field('has_applications_of_ebflow');
?>

<?php if ( $has_applications_of_ebflow === TRUE ): ?>

    <div class="applications-of-ebflow">

        <div class="applications-of-ebflow-inner">

            <?php
            $applications_of_ebflow = get_field('applications_of_ebflow');
            while ( have_rows('applications_of_ebflow') ): the_row();
                $heading = get_sub_field('heading');
                $application_sectors = get_sub_field('application_sectors');
                $enquiry_link = get_sub_field('enquiry_link');
            ?>

                <?php if ( $heading != '' ): ?><h2 class="aoe-heading"><?php echo $heading; ?></h2><?php endif; ?>

                <?php if ( $application_sectors != '') : ?>

                    <div class="aoe-application-sectors">

                        <?php
                        while ( have_rows('application_sectors') ): the_row();
                            $image = get_sub_field('image');
                            $heading = get_sub_field('heading');
                            $sector_applications = get_sub_field('sector_applications');
                        ?>

                            <div class="aoe-application-sector">

                                <?php if ( $image != '' ): ?>

                                    <div class="aoe-application-sector-image-contain">

                                        <img class="aoe-application-sector-image" alt="sector image" src="<?php echo $image; ?>">

                                    </div>

                                <?php endif; ?>

                                <div class="aoe-application-sector-content">

                                    <?php if ( $heading != '' ): ?>

                                        <h3 class="aoe-sector-heading"><?php echo $heading; ?></h3>

                                    <?php endif; ?>

                                    <?php if ( $sector_applications != '' ): ?>

                                        <div class="sector-applications">

                                            <?php
                                            while ( have_rows('application_sectors') ): the_row();
                                                $application = get_sub_field('application');
                                            ?>

                                                <div class="sector-application">

                                                    <?php echo $application; ?>

                                                </div>

                                            <?php endwhile; ?>

                                        </div>

                                    <?php endif; ?>

                                </div>

                            </div>

                        <?php endwhile; ?>

                    </div>

                <?php endif; ?>

                <?php if ( $enquiry_link != '' ): ?>

                    <div class="aoe-enquiry">
                        <a href="<?php echo $enquiry_link; ?>" class="box-link"></a>
                        <div class="enquiry-text">Enquire about your application</div>
                    </div>

                <?php endif; ?>

            <?php endwhile; ?>

        </div>

    </div>

<?php endif; ?>

">
询问你的申请
我还可以附加我的ACF屏幕抓图:

我敢肯定我没有正确地调用我的中继器字段,但我不记得以前我是如何处理这种情况的。

而不是这个

<?php
$sector_applications = get_sub_field('sector_applications');
?>
然后调用你的sub_字段。它是一个中继器中的中继器。就像foreach中的foreach循环。你调用它就像它是一个字段,但实际上有行

have_rows() – allows us to loop through the available rows in a repeater / flexible content field
get_sub_field() – returns the value of a sub field (from the current repeater in “has_sub_field”)
the_sub_field() – displays the value of a sub field (from the current repeater in “has_sub_field”)
更多信息和一个很好的例子可以在

我想问题就在这里,我已经修改了你的部分代码

<?php
while ( have_rows('application_sectors') ): the_row();
$image = get_sub_field('image');
$heading = get_sub_field('heading');

while ( have_rows('sector_applications') ): the_row();
?>

您的结构是: 中继器

  • 子字段(也称为获取字段)
但你不能进入另一个中继器

在我的例子中,你有

中继器

  • 子字段(也称为获取字段)
  • 中继器内部中继器
    • 然后,您可以再次从中继器的这一部分读取sub_字段

“由于php错误,页面无法加载“,错误是什么?错误500-我想我在迭代时可能必须使用'the_sub_field'而不是'get_the_field',这听起来对你正确吗。打开调试模式以从服务器获取真正的错误消息。非常感谢你的帮助,我觉得很愚蠢,但我已经在使用你说要使用的行了。请允许我请你操作我提供的代码块,以便我能看到你将在哪里使用它?@JasonIsMyName修改了我的答案谢谢你兄弟!干得好c:我以前至少做过20次,从来没有遇到过问题。这一次,即使看了这些文件,我也看不出哪里出了问题!再次感谢!
<?php
while ( have_rows('application_sectors') ): the_row();
$image = get_sub_field('image');
$heading = get_sub_field('heading');

while ( have_rows('sector_applications') ): the_row();
?>