I would like to automatically display all images that belong to a post automatically at the end of the content on single.php
I found this code which was written for wp 2.7 and it works partially. Hoping someone can point me in the right direction or post an alternative way of doing this.
<?php
$post_parent = get_post($post->ID, ARRAY_A);
$parent = $post_parent['post_parent'];
$attachments = get_children( array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'orderby' => 'menu_order ASC, ID', 'order' => 'DESC') );
foreach($attachments as $id => $attachment) :
echo wp_get_attachment_link($id, 'thumbnail', true);
endforeach;
?>
The above code works but instead of only showing images/attachments for the specific post, it's displaying ALL images that have been uploaded to the entire WordPress site below every post.