Home › Forums › Add-ons › Repeater Field › Accessing Post Object in a Nested Repeater › Reply To: Accessing Post Object in a Nested Repeater
This has been solved. The code is below.
<?php
/**
* The template for displaying all pages
*
* Template Name: Feature Comparison
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package Merchant_Services
*/
get_header();
?>
<div id="primary" class="content-area">
<main id="main" class="site-main">
<?php get_template_part( 'template-parts/content','hero' ); ?>
<div class="comparison-box-wrapping">
<?php $loop = new WP_Query( array(
'post_type' => 'comparison_tables',
'orderby' => 'date',
'order' => 'DESC',
'posts_per_page' => '5') );
?>
<?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 $legends = get_field('legend');
if($legends){
foreach($legends as $legend){
$company_attributes = $legend['company_attributes'];
foreach ($company_attributes as $company_attribute) {
$companies = $company_attribute['company'];
$count++;
//limit the count to only get the logos from the first legend
if( has_post_thumbnail($companies->ID) && $count < 6) {
echo "<th>";
$thumb = get_the_post_thumbnail($companies->ID, 'full');
echo $thumb;
echo "</th>";
};
}
}
} ; ?>
</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 -->
<?php get_template_part( 'template-parts/content','disclosure-dark' ); ?>
</main><!-- #main -->
</div><!-- #primary -->
<?php
get_footer();
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.