Get an array containing ONLY post IDs of attached images
The following code should work for you, $images = get_children( array(‘post_parent’ => $post_id, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’) ); $image_ids = array(); if($images){ foreach( $images as $imageID => $imagePost ){ array_push($image_ids, $imageID); } } The array $image_ids would get you the image IDs.