Support

Account

Home Forums Front-end Issues Display Relationship Image

Unread

Display Relationship Image

  • Hi all,
    
    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:
    
    <?php 
    	$posts = get_field('product_relationship');
    
    if( $posts ): ?>
    	<ul>
    	<?php foreach( $posts as $post ): // variable must NOT be called $post (IMPORTANT) ?>
    	    <li>
    			<?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>
    			<div class="productinshoptitle">
    			<?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>
    	    </li>
    	<?php endforeach; ?>
    	</ul>
    <?php endif; ?>
    
    Does anyone know what I am doing wrong?
Viewing 1 post (of 1 total)

The topic ‘Display Relationship Image’ is closed to new replies.