What's the best way to display the URL to an image that's attached to a post and is outside the loop? This is the code I'm using to display the results:
<?php foreach($duplicates as $postID) { ?>
<?php $postData = get_post( $postID );?>
<?php if(esc_html(get_the_category($postID)[0]->slug) == 'group-a-first'):?>
group a first (only) - <?php print $postData->post_title;?><br>
<?php endif;?>
<?php } ?>
I was able get results using <?php print wp_get_attachment_image_src( get_post_thumbnail_id( $postID ), 'thumbnail' )[0];?>
but it works only if a post has a featured image.
$duplicates
variable ? And do you want show a default image if post has not a featured image ? – CodeMascot Aug 25 '16 at 5:38$duplicates
just shows the post ID. Just looking for a way to display the path of an attached image to a post. – Gregory Schultz Aug 25 '16 at 5:45