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
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.