I explain my problem:
- I create a post with an image
- get_children - wp_get_attachment_image functions returns that image
- I delete post image and add a different one
- get_children - wp_get_attachment_image functions returns the two images (although the image that has been removed and is no longer in the post)
The code:
$args = array('post_parent' => get_the_ID(),
'post_type' => 'attachment',
'post_mime_type' => 'image'
);
$images = get_children( $args );
if ($images)
{
foreach ($images as $image)
{
echo wp_get_attachment_image($image->ID, 'full');
}
}