Support

Account

Home Forums Front-end Issues get the feature img from post objects Reply To: get the feature img from post objects

  • Hi @Chris

    Just to clarify, the related products (1, 2 and 3) will be saved to another product, not the taxonomy.

    The taxonomy loop you speak of is to loop through products right?

    Within the products loop, you can load the related products like so:

    
    $related_1 = get_field('related_1');
    

    For performance reasons, I would set the return value setting to ‘Post ID’ for each related product field.

    Now that you have the related product ID (get_field example above), you can load the related product image and link like so:

    
    <?php 
    
    if( $related_1 )
    {
    	echo '<a href="' . get_permalink( $related_1 ) . '">';
    		 echo get_the_post_thumbnail( $related_1, 'thumbnail' );
    	echo '</a>';
    
    }
    
    ?>
    

    Reference: http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail

    Hope that helps.

    Thanks
    E