Hi there, great plugin, I use it all the time. I also bought the Gallery plugin, works like a charm!
Question: I have two custom post types, for a client that manufactures custom products. The CPT’s are “design” and “designer”. I add a post for the designer. Then I add a post for the design, and use the relationship field (“designer_name”) to assign the designer of that design (and show a thumbnail and a link to their full profile). It was working perfectly when I was using the built-in Featured Image, like so:
<?php
$args = array(
'numberposts' => -1,
'post_type' => 'design',
'meta_query' => array(
array(
'key' => 'designer_name',
'value' => $post->ID,
'compare' => 'LIKE',
)
) );
$posts_array = get_posts( $args );
if( $posts_array ) {
foreach( $posts_array as $related ) {
echo get_the_post_thumbnail($related->ID, 'thumbnail');
echo '<a href="' . $related->guid . '">' . $related->post_title . '</a>';
}
}
?>
This works great, but now I’m using the Gallery plugin, because I have more than one image for each designer/design. But on this particular area, I want to ONLY get the first image from the gallery, like so:
<?php $gallery_images = get_field('gallery'); ?>
<img src="<?php echo $gallery_images[0]['url']; ?>" />
This works fine by itself, elsewhere on the site, but how would I combine the first bit of code with the second: basically how do I replace the get_the_post_thumbnail with this gallery code above?
Thanks!