diff --git a/wp-admin/upload.php b/wp-admin/upload.php index e7b5717adc..3586051d4f 100644 --- a/wp-admin/upload.php +++ b/wp-admin/upload.php @@ -20,7 +20,7 @@ if ( isset($_GET['find_detached']) ) { if ( !current_user_can('edit_posts') ) wp_die( __('You are not allowed to scan for lost attachments.') ); - $all_posts = implode( ',', $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type IN ('" . join("', '", get_post_types() ) . "')")); + $all_posts = implode( ',', $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type NOT IN ('attachment', '" . join("', '", get_post_types( array( 'public' => false ) ) ) . "')" ) ); $lost = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent > '0' and post_parent NOT IN ($all_posts)"); $_GET['detached'] = 1;