I am using a post object field to allow my users to select a blog post that will display on their home page. I am able to do that, and call most of the blogs content using WP Hooks. However, there is also a repeater field associated with the blog that I need to display, and I am having a lot of trouble getting that to work. The repeater fields named ‘authors’ and its subfield is ‘author.
<div style=”width:49%;float:left;margin:.5%”>
<?php
$post_object = get_field(‘blog2’);
if( $post_object ):
// override $post
$post = $post_object;
setup_postdata( $post );
?>
<div>
<article class=”teaser5″>
” class=”teaser5-header”>
<figure class=”teaser5-image “>
<span class=”img1″ style=”padding-top: 75%”>
<?php the_post_thumbnail( ‘medium’ ); ?>
</span>
</figure>
<h3 class=”teaser5-title -ts:4″> <?php the_title(); ?> </h3>
<p>
<?php echo wp_trim_words( get_the_content(), 60 );?>
</p>
<div style=”width:100%;overflow:auto;”>
<p style=”float:left;width:50%;”><?php the_time(‘M-d-Y’); ?></p>
<p style=”float:left;width:50%;”>” title=”<?php echo esc_attr( get_the_author() ); ?>”><?php the_author(); ?></p>
<?php
// check if the repeater field has rows of data
if( have_rows(‘authors’) ):
// loop through the rows of data
while ( have_rows(‘authors’) ) : the_row();
// display a sub field value
the_sub_field(‘author’);
endwhile;
else :
// no rows found
endif;
?>
</div>
</article>
</div>
<?php wp_reset_postdata(); // IMPORTANT – reset the $post object so the rest of the page works correctly ?>
<?php endif; ?>
</div>
</div>
No matter what I do I can’t get that repeater field at the end to show up on the page. Any advice any of you can give is hugely appreciated. Thank you.