Home Forums Front-end Issues Extracting Post Object data from within a Repeater Reply To: Extracting Post Object data from within a Repeater

  • Hi Guys
    I am trying to achieve like this.. I am trying to show a post object as repeater inside 2 nested repeater field.. I am using this repeater and post object in a page template called page-bagels.php . These 2 repeater showing the 2 row as output as expected. But the post object is not showing or not returning value. Rather it is returning value of the page. Like where I have used <?php the_title(); ?> it is returning the page title and not returning the post object title. My code is as below

      <?php while ( have_posts() ) : the_post(); ?>        
    		<div class="main-content">    	
    			<div class="main-wrap">                	            
    				<div class="col-sm-12">                
    					<div class="breadcrumbs">                    
    						<?php if(function_exists('bcn_display'))                {                    bcn_display();                }?>                  
    					</div>  <!-- breadcrambs ends here -->                              
    				</div><!-- col-sm-12 ends here -->                                    
    				<?php 				// check for rows (parent repeater)				
    				if( have_rows('product_page') ): ?>                        
    				<div class="col-lg-12 row product-row">                        	
    					// loop through rows (parent repeater)					
    					while( have_rows('product_page') ): the_row(); ?>                            
    					<div class="col-sm-12">                            
    						<div class="marque">                                
    							<span class="brand-lg"><img src="<?php the_sub_field('brand_image'); ?>" /></span>                            </div>                        
    					// check for rows (sub repeater)							
    					if( have_rows('post_repeater') ): ?>                                                                                                                        <div class="col-sm-12 product-item-row">                               
    					// loop through rows (sub repeater)					
    					while( have_rows('post_repeater') ): the_row();?>                                
    					<div class="col-sm-3 product-item">                	                                        
    					<?php	$postobject = get_sub_field('product_post'); ?>      
    						<a href="<?php $postURL = get_permalink($postobject->ID);?>">                        
    						<img class="product-img" src="<?php bloginfo('template_directory');?>/images/product-images/321600_moelleux_blanc_trepais.png" width="100%" />                        
    						<p class="product-name"><?php the_title();?></p>                        
    					<p class="product-seemore">See More</p>                    		</a>                                                                       
    					</div><!-- col ends here -->                                 
    					<?php endwhile; ?>                                
    					</div><!-- col Product Items row here -->                                
    					<?php endif; //if( get_sub_field('items') ): ?>                                
    					<?php endwhile; // while( has_sub_field('to-do_lists') ): ?>                        
    				</div><!-- col lg 12 ends here or row ends here -->                                  	
    				<?php endif; // if( get_field('to-do_lists') ): ?>			
    				<?php endwhile; // end of the loop. ?>                  
    					</div><!-- main wrap ends here -->               
    				<div class="clr"></div>    
    		</div><!-- main content ends here -->

    So in this code you can see the post object is also a repeater.. So it means I am using 3 repeaters. If you see the code you will get it

    Here is the output I am getting

    So any help is appreciated.