get_results(”
SELECT ID, post_title
FROM $wpdb->posts
WHERE post_type = ‘attachment’
AND ID NOT IN (
SELECT post_id
FROM $wpdb->postmeta
WHERE meta_key = ‘_thumbnail_id’
)
“);
// 输出结果
if ($unreferenced_attachments) {
echo ‘
‘;
foreach ($unreferenced_attachments as $attachment) {
echo ‘