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.




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) {

<? get_attachment_files(); ?>

Leave a comment