Home Forums Front-end Issues Repeater + Post object in CPT loop


Repeater + Post object in CPT loop

  • Hi Guys,

    I’m having trouble with the ACF Repeater and Post object.

    I have a CPT loop and I want a repeater within the loop displaying a post type. But all I seem to get is the first row. If I use the same repeater outside the loop it does work correctly. Can someone please help me?


    $args = array( 'post_type' => 'slides' );
     $loop = new WP_Query( $args );
     while ( $loop->have_posts() ) : $loop->the_post(); ?>
    <?php if(get_field('type_pagina') == "Trainingen"): ?>
    <div class="training-container">
        <div class="trainingen-inner">
    		<?php if(get_field('trainingen')): ?>
    			<?php while ( has_sub_field('trainingen') ) : the_row(); ?>
    				<?php $post_object = get_sub_field('training');
    					if( $post_object ): 
    					$post = $post_object;
    					setup_postdata( $post );  ?>
    			    			<?php the_title(); ?>
        					<?php endif; ?>
    			<?php endwhile;  ?>
    			<?php wp_reset_postdata(); ?>
    		<?php endif;?> 
    	<?php endif; ?>
    <?php endwhile; ?>
  • See my explanation here for why this is happening and let me know if you have any questions.

  • Thanks man, that works like a charm! Hero of the day award to you!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.