Uploaded images are stored as posts with the type “attachment”. Use get_posts() and query for all attachments:

$args = array(
                'post_type' => 'attachment',
                'numberposts' => -1,
                'post_mime_type' =>'image',
                'post_status' => 'inherit',
                'post_parent' => null, // any parent
           );
$attachments = get_posts($args);
if ($attachments) {
    foreach ($attachments as $post) {
         setup_postdata($post);
         the_title();
         the_attachment_link($post->ID, false);
         the_excerpt();
     }
}

Now All images are displayed.

Have any doubt, then comment here!

Leave a Reply

Your email address will not be published. Required fields are marked *