I have a relationship field between two custom post types. Everything is working the way I want, except I cannot get the featured image to display. Here is my code:
$posts = get_field('product_relationship');
if( $posts ): ?>
<?php foreach( $posts as $post ): // variable must NOT be called $post (IMPORTANT) ?>
<?php $prodimage = get_field($post->ID,'product_image',true); ?>
<?php echo get_field('product_image'); ?>
<a href="<?php echo $prodimage['url']; ?>" alt="<?php echo $prodimage['alt']; ?>" /></a>
<?php the_field('product_name', $post->ID); ?></div>
<a href="<?php echo get_permalink( $post->ID ); ?>"><?php echo get_the_title( $post->ID ); ?><br /></a>
<div class="shopproductexcerpt"><?php echo the_excerpt(); ?></div>
<?php endforeach; ?>
<?php endif; ?>
Does anyone know what I am doing wrong?
Viewing 1 post (of 1 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users