ACF子组第二图像未显示

问题描述 投票:0回答:1

我是WordPress的新手,我想用ACF创建一个动态的“团队组件”。为此,我为“标题”和“子行”创建了两个字段,并为一个“个人资料”组创建了一个子组,其中子分组为“ profile_1”,“ profile_2”,...

每个子组都有三个不同的字段:“ full_name”,“ job_titel”,“ image”。

现在,使用第一个子字段“ profile_1”,一切都很好。第二秒钟,我可以从后端拉“ full_name”和“ job_titel”,但不能拉“ image”。如果我键入print_r("profiles"),则只能看到数组“ image”中不存在“ profile_2”,它存在于“ profile_1”中,尽管我以前是通过wp-admin上传的。

<?php
        $profiles = get_field('profiles_team_component');
        if ($profiles): ?>

        <!-- Profile 1 -->
        <div class="profile-wrapper">
            <div class="image-wrapper">
                <div class="image" style="background-image: url(<?php echo $profiles['profile_1']['image']['sizes']['profile-pic'] ?>) "></div>
            </div>
            <h4 class="ourteam"><?php echo $profiles['profile_1']['full_name'] ?></h4>
            <p class="ourteam"><?php echo $profiles['profile_1']['job_titel'] ?></p>
        </div>

        <!-- Profile 2 -->
        <div class="profile-wrapper">
            <div class="image-wrapper">
                <div class="image" style="background-image: url(<?php echo $profiles['profile_2']['image']['sizes']['profile-pic'] ?>) "></div>
            </div>
            <h4 class="ourteam"><?php echo $profiles['profile_2']['full_name'] ?></h4>
            <p class="ourteam"><?php echo $profiles['profile_2']['job_titel'] ?></p>
        </div>
        <?php endif; ?>

感谢您的帮助!

php wordpress advanced-custom-fields
1个回答
0
投票

如果要从ACF生成动态“团队组件”,为此,您需要安装ACF Repeater字段,以便可以轻松地动态生成团队组件并使用PHP循环显示每个文件。有关更多详细信息,请单击以下链接:ACF

© www.soinside.com 2019 - 2024. All rights reserved.