I am sure some of you out there know the answer to this but I can not find the correct solution. Everything that I try give me the wrong results.
I am trying to show the images that have been inserted into a post and display them in the single.php page. I either get all of the images that are in my wordbress blog or the last two images that were imported. All that works but I only want to show the ones in the particular post.
$args = array(
'post_parent' => $post->ID,
'post_type' => 'any',
'post_mime_type' => 'image',
'numberposts' => -1,
'post_status' =>'any',
);
$attachments = get_children($args);
if ($attachments) {
foreach ($attachments as $attachment) {
$img = wp_get_attachment_thumb_url($attachment->ID);
$link = chop($img,'-150x150.jpg');
echo "<ul class='workPic'> <li class='thumbframe'>";
echo "<div class='thumbnail'>";
echo "<a href='".$link.".jpg' target='_blank'>";
echo "<img src='".$img."' alt='read more'/>";
echo "</a></div></li></ul>";
}
}
Please help as I have been struggling with this for days and cant seem to figure out the solution. I think its in the $args array but I am not sure.
Thanks!