Using relationship within repeater and pulling custom post type custom field data.
The goal here is to create a sort of low-tech banner/advertising functionality by using a custom post type (advertisements) and display in zones on a custom template using ACF.
The main obstacle here is on the template the ad 'zones' are created using a relationship field nested in a repeater with the intention of allowing for multiple 'zones' each containing 1 or more banners (advertisements).
We are able to display values from custom field(s) banner_url and banner_embed_code without problem but when trying to display an image from ACF is posing very tricky. Reviewed the nested repeater article and relationship docs but can't seem to find a solution.
Existing code on the template page (which is also a CPT): ` <?php $post_objects = get_field('advertisement_zone_settings'); if( $post_objects ): ?>
-
<?php
if ($post_object['advertisement']):
foreach ($post_object['advertisement'] as $item ) :?>
<li><?php
$type = ($item->image_type);
$image = get_field('banner_image', '471');
if (($type) == ('URL')); { ?>
<a href="<?php echo $item->sponsor_url; ?>"><img src="<?php echo $item->banner_url; ?>" /> </a><?php
} if (($type) == ('Campaign Code')); {
echo $item->banner_embed_code;
} if (($type) == ('Media Library/Upload')); { ?>
<a href="<?php echo $item->sponsor_url; ?>"><img src="<?php echo $image[0]; ?>" /> </a><?php
} ?>
</li>
<?php endforeach;
endif; ?>
</ul>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>