Created
September 20, 2022 19:12
-
-
Save ideadude/116721abb8ce3ceb2a1dcc47afc22289 to your computer and use it in GitHub Desktop.
SQL Query to find images (and other attachments) that aren't being used as featured images.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT p.ID | |
FROM wp_posts p | |
LEFT JOIN wp_postmeta pm ON p.ID = pm.post_id | |
AND pm.meta_key = '_thumbnail_id' | |
WHERE p.post_type = 'attachment' | |
AND post_status = 'publish' | |
AND pm.meta_id IS NULL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment