I am trying to show images that are attached to a page/post in Wordpress.
I don't want to insert anything into the post only attach it.
Just now I have clicked 'Add Media' and chosen multiple images that were already uploaded in the past and have used the following PHP.
$images =& get_children( array (
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image'
));
print_r($images);
if ( empty($images) ) {
// no attachments here
} else {
foreach ( $images as $attachment_id => $attachment ) {
echo wp_get_attachment_image( $attachment_id, 'thumbnail' );
}
}
This doesn't pick up attached images but if I upload an image to this post and then attach it as above then it works.
So my question is, how do I get previously uploaded to the site content to show in my code above