wordpress snippets last updated   : January 29, 2015
we now have 646 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) {
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