Skip to content

Instantly share code, notes, and snippets.

@primedime primedime/feature-comparison.php Secret
Last active Jan 22, 2019

Embed
What would you like to do?
Nested repeater with post object ACF
<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>&nbsp;</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
You can’t perform that action at this time.