0
votes

I am new to WordPress and I wanted to create a dynamic "team-component" with ACF. For this I have created two fields for "headline" and "subline" + one "profiles" group with sub-groups "profile_1", "profile_2",...

Every sub-group has three different fields: "full_name", "job_titel", "image".

Now, with first sub-field "profile_1" everything is fine. With second I am able to pull "full_name" and "job_titel" but not "image" from back-end. If I type print_r("profiles"), all I can see is that within array "image" is not present for "profile_2" and it is for "profile_1", although I have previously uploaded through 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; ?>

Thanks for your help!

1

1 Answers

0
votes

If you want to generate dynamic 'team-component' from ACF, for that you would need to install ACF Repeater field so you can easily generate dynamically team-component and show each of the filed using PHP loops. For more details, you should follow below link: ACF