Support

Account

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

  • Hi!

    If I understand you correctly this should do it

    
    
    <?php 
    	//Loops through the repeater
    while (have_rows('favorite_cars')) {
    	the_row();
    	
    	//fetches the post object field. Assumes this is a single value, if they can select more than one you have to do a foreach loop here like the one in the example above
    	$car_object = get_sub_field('select_car');
    	if($car_object){
    		//Fetch the image field from the carsandtrucks post
    		$image = get_field('main_image', $car_object->ID);
    	}
    	
    	//Echo out the image with the medium size. Change this as you like!
    	echo '<img src="' . $image['sizes']['medium'] . '" width="' . $image['sizes']['medium-width'] . '" height="' . $image['sizes']['medium-height'] . '" alt="' . $image['alt'] . '" />';
    	
    	
    } 
    ?>