-
-
Save primedime/3d79cd5d01e794b659cb8e4f07603715 to your computer and use it in GitHub Desktop.
Nested repeater with post object ACF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="comparison-box-wrapping"> | |
<?php $loop = new WP_Query( array( | |
'post_type' => 'comparison_tables', | |
'orderby' => 'date', | |
'order' => 'DESC', | |
'posts_per_page' => '10') ); | |
?> | |
<?php while( $loop->have_posts() ) : $loop->the_post(); ?> | |
<div class="comparison-block"> | |
<div class="recommend-header"><h2 class="green-medium"><?php the_title(); ?></h2></div> | |
<table> | |
<thead> | |
<tr> | |
<th> </th> | |
<?php if ( have_rows( 'legend' ) ) : ?> | |
<?php while( have_rows('company_attributes') ): the_row(); ?> | |
<?php $post_objects = get_sub_field('company'); ?> | |
<?php if($post_objects): ?> | |
<?php $post = $post_objects; setup_postdata( $post ); ?> | |
<th> | |
<div class="company-header"> | |
<div class="image"> | |
<?php | |
if( has_post_thumbnail() ) { | |
the_post_thumbnail('full'); | |
} | |
?> | |
</div> | |
<div class="review-link"> | |
<a href="<?php the_permalink(); ?>">Read Review</a> | |
</div> | |
</div> <!-- company-header END --> | |
</th> | |
<?php endif; ?> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
</tr> | |
</thead> | |
<tbody> | |
<?php if ( have_rows( 'legend' ) ) : ?> | |
<?php while( have_rows('legend') ): the_row(); | |
$legend_title = get_sub_field('legend_title'); | |
?> | |
<tr> | |
<td><p><?php echo $legend_title; ?></p></td> | |
<?php while ( have_rows( 'company_attributes' ) ) : the_row(); | |
$attribute = get_sub_field('attribute'); | |
?> | |
<td><?php echo $attribute; ?></td> | |
<?php endwhile; ?> | |
</tr> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
</tbody> | |
</table> | |
</div> <!-- comparison-block END --> | |
<?php endwhile; ?> | |
</div> <!-- comparison-box-wrapping END --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment