Reputation: 51
I'm working on ACF Plugin in Wordpress and I have this HTML Code that split into 3 parts. the first part is the parent Group inside this parent Group has also child group and inside child Group has repeater. I tried to solve it like this one [4] but it didn't work. These some images to explain more
<!--The Parent Group (section2_technology)-->
<div class="section2">
<div class="container">
<div class="right">
<div class="frame">
<!-- The (qoute) text -->
We use modern, proven technologies and approaches that allow us to effectively extend and scale our products.
</div>
</div>
<div class="left">
<div class="top">
<hr>
<span>MOBILE</span>
<hr>
</div>
<!-- The Child Group class='mobile' -->
<div class="bottom" id="mobile">
<div data-aos="flip-up">
<div class="slide-down frame1">
<div class="main-hover">
<div class="mobile">
IOS
</div>
<div class="split"></div>
<div class="content-div">
<div class="slide-down__top">
<!-- The Repeater class='type' -->
<div class="type">
<img src="" alt="" class="mobileicons-img">
<div class="name"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div data-aos="flip-down" data-aos-delay="200">
<div class="slide-down">
<div class="main-hover">
<div class="mobile">
ANDROID
</div>
<div class="split"></div>
<div class="content-div">
<div class="slide-down__top">
<!-- This is the repeater class='type' -->
<div class="type">
<img src="" alt="" class="mobileicons-img">
<div class="name">Java</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Upvotes: 1
Views: 1607
Reputation: 402
Your PHP should look something like this:
<?php if ( have_rows('parent-group') ): ?>
<!-- html before -->
<?php while ( have_rows('parent-group') ) : the_row(); ?>
<?php if ( have_rows('child-group') ): ?>
<!-- html before -->
<?php while ( have_rows('child-group') ) : the_row(); ?>
<?php if ( have_rows('repeater') ): ?>
<!-- html before -->
<?php while ( have_rows('repeater') ) : the_row(); ?>
<!-- item contents -->
<?php the_sub_field("image") ?>
<?php the_sub_field("title") ?>
<!-- item contents -->
<?php endwhile; ?>
<!-- html after -->
<?php endif; ?>
<?php endwhile; ?>
<!-- html after -->
<?php endif; ?>
<?php endwhile; ?>
<!-- html after -->
<?php endif; ?>
Remember that have_rows() defaults to the current post.
To get the rows from a diffrent post use: have_rows('key', $postID);
Or if you use the options page: have_rows('key', "options");
Upvotes: 3