i have a Repeater and in that Repeater is a Group and inside this Group is another Repeater.
Now i want to get the values from the Repeater inside the Group.

这是我的 struct :

-partner (repeater)

--info (group)
---logo
---headline
---subline
---description
---facts (repeater)
----fact

这是我的Code Kinda的样子:

<?php 
$partner = get_sub_field('partner');
?>

<div>
    <?php while( have_rows('partner')): the_row();
    $info = get_sub_field('info);
    ?>

    Here is some output of the Group $info that works perfectly..

        <?php while( have_rows('info')): the_row(); ?>
            <?php while(have_rows('facts')): the_row();
            $fact = get_sub_field('fact');
                <?php print_r($fact) ?> <--- No outcome!
            <?php endwhile; ?>
        <?php endwhile;?>

    <?php endwhile; ?>
</div>

我已经在网上搜索过了..这就是我找到的东西..但还是不起作用.

推荐答案

我调整了你的PHP代码以正确地在字段中循环.首先,我使用了Foreach循环来迭代顶级的‘partner’中继器字段.在每个"partner"条目中,我访问了"info"组,并提取了它的字段.然后,使用另一个foreach循环来迭代‘info’组中的‘FACTS’中继器字段. 尝尝这个

<?php 
$partners = get_field('partner');  
if($partners):
    foreach($partners as $partner):
        $info = $partner['info'];  // 'info' is a group inside the 'partner' repeater

        // Output some fields from the 'info' group
        echo $info['headline'];
        echo $info['subline'];
        // ... other fields from 'info'

        // Now loop through 'facts' repeater inside 'info' group
        if($info['facts']):
            foreach($info['facts'] as $fact):
                echo $fact['fact'];  // Output the 'fact' field inside the 'facts' repeater
            endforeach;
        endif;
    endforeach;
endif;
?>

<div>
    <!-- Your HTML and output here -->
</div>

Php相关问答推荐

为WooCommerce中的特定用户角色指定促销价格

基于验证动态更改输入字段类(名称密码)&

WooCommerce产品按特定元数据的自定义数字排序选项

如何减少Laravel分页中的链接数

用于计算付款费用的WooCommerce管理编辑产品中的自定义复选框

PHP从响应应用程序json获取文件代码和URL

使用php创建表格和插入数据

将一个情态形式放在细丝v3中的形式中间

如何使用 AJAX、PHP 和 MYSQL 在 Select 项目时在文本框中填充数据

对 WooCommerce 购物车和 checkout 中显示的运输方式进行排序

Google Drive API 服务->文件->get('root') 失败并显示找不到文件. (范围问题?)

使用其ID查询和捕获与订单相关的其他详细信息的shopware 6方法

批量作业(job)提交错误无法处理所有文档,uris 似乎正确?

PHP 中的正则表达式,具有字符范围,但不包括特定字符

为什么 8.0 之前的 PHP 版本拒绝命名空间Random\Namespace作为无效语法?

为什么 AJAX 请求没有通过 is_ajax_request() codeigniter 的条件?

Symfony 6 中的入口点 (public/index.php) - 它是如何工作的?

Symfony 自定义注销

如何使用先前 SELECT 的结果来 SELECT SQL 数据

PHP - 如何获取发送到脚本的查询参数