Home › Forums › Add-ons › Repeater Field › Return one row of nested repeater sub_fields
I think I said that right. Trying to display single row of sub_fields that is in a repeater in a repeater.
I’d like to show the first row on the index of posts as a teaser and displays the remaining of the rows for the single post.
I want to turn off the repeater and display the first row of subfields. How many more ways can I say this 🙂
Getting closer, but still missing some pieces. I’ve managed to show the first stat for the first post but the rest of the posts don’t show. If I change the count to 4 the loop shows the next stat in the same post. After the loop shows all the stats in that first post it moves on to the next post displaying until reaching the count break. Thanks for any help.
<?php
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query('showposts=4&post_type=market-minute'.'&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post();
?>
<article class="row">
<h2 class="col-sm-9 col-sm-offset-3"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php if( have_rows('mm-stats') ): ?>
<?php while ( have_rows('mm-stats') ) : the_row(); ?>
<?php if( have_rows('article_stat') ): ?>
<div class="archive-stat col-sm-3 text-right">
<?php while ( have_rows('article_stat') ): the_row(); ?>
<?php $i++; ?>
<?php if( $i > 1 ):
break; ?>
<?php endif; ?>
<h4><?php the_sub_field('name'); ?></h4>
<div class="stat-box" rel="tooltip" data-toggle="tooltip" data-placement="top" title="Last Year to Date">
<p class="value">
<?php the_sub_field( 'value' ); ?><i class="fa fa-info-circle"></i>
</p>
<p class="indicator <?php the_sub_field('indicator'); ?>">
<i class="fa fa-arrow-<?php the_sub_field('indicator'); ?>"></i><?php the_sub_field( 'percent' ); ?>% <label><span>Lytd</span></label>
</p>
</div>
<a class="read-more" href="<?php the_permalink(); ?>">More Stats</a>
<?php endwhile; ?>
</div>
<?php endif; endwhile; endif; ?>
<p class="meta col-sm-9"><em>
<?php echo the_time('F jS, Y'); ?>
</em></p>
<div class="col-sm-9">
<?php
if(!$post->post_excerpt) {
the_content();
} else {
the_excerpt();
}
?>
</div>
</article>
<hr />
<?php endwhile;?>
Yeah for solutions!
http://stackoverflow.com/questions/21135959/get-first-row-image-of-acf-repeater-field
My Code
<?php $first_mm_stats = true; ?
<?php while ( $first_mm_stats && have_rows('mm-stats') ) : the_row(); ?>
<?php $first_article_stat = true; ?>
<?php while ( $first_article_stat && has_sub_field('article_stat') ): ?>
<h4><?php the_sub_field('name'); ?></h4>
<div class="stat-box" rel="tooltip" data-toggle="tooltip" data-placement="top" title="Last Year to Date">
<p class="value">
<?php the_sub_field( 'value' ); ?><i class="fa fa-info-circle"></i>
</p>
<p class="indicator <?php the_sub_field('indicator'); ?>">
<i class="fa fa-arrow-<?php the_sub_field('indicator'); ?>"></i><?php the_sub_field( 'percent' ); ?>% <label><span>Lytd</span></label>
</p>
</div>
<a class="read-more" href="<?php the_permalink(); ?>">More Stats</a>
<?php $first_article_stat = false; ?>
<?php endwhile; ?>
<?php $first_mm_stats = false; ?>
<?php endwhile; ?>
</div>
The topic ‘Return one row of nested repeater sub_fields’ is closed to new replies.
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.