List all unattached files in media library

Adding the first snippet to the functions.php of your wordpress theme then add the second snippet into your wordpress template. Once added this snippet will display thumbnails of unattached image files and links to other file types.

Code Snippet:

function get_attachment_files(){
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => 0
$attachments = get_posts($args);

if ($attachments) {
foreach ($attachments as $post) {

Code Snippet:

<? get_attachment_files(); ?>

Comments  Leave a Reply

  1. MD Ariful Islam Sonnet March 20, 2013 at 2:51 pm

    Thanks sir

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!