wordpress snippets last updated   : September 29, 2014
we now have 639 snippets

List all unattached files in media library

wordpress snippet

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.

snippet :  PHPcopy
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) {
        setup_postdata($post);
        the_attachment_link($post->ID);
    }
 }
}
source →
snippet :  PHPcopy
<? get_attachment_files(); ?>
source →

Did you like this post? If so please share it with your friends. Thanks!

  • http://www.facebook.com/Sonnet01 MD Ariful Islam Sonnet

    Thanks sir