I have created a 'related posts' custom field and would like to loop through all the posts that are added as a relation and show a bit of info from each (the title, a link and the featured image). I've got the title and permalink coming through nicely, but for some reason I can't get the related posts featured image to appear. I'm hoping someone can point me in the right direction?
Here's the code I'm using to create an array of all the post info:
$relatedPosts = get_custom_field('relatedposts:to_array', 'get_post');
foreach ($relatedPosts as $p) {
$postTitle = $p['post_title'];
$postID = $p['ID'];
$postPermalink = $p['guid'];
$postTNID = $p['thumbnail_id]'];
$post_html[] = '<div class="relPost"><a href="' . $postPermalink . '" title="' . $postTitle . '">' . $postTitle . '</a> '. wp_get_attachment_image($postTNID). ' </div>';
}//end foreach
Then I use the following to show it on the page:
if ($relatedPosts != "") {
echo implode("\n", $post_html);
}
Everything except the image works...