Skip to content

Instantly share code, notes, and snippets.

@BramDriesen
Created August 4, 2021 05:54
Show Gist options
  • Save BramDriesen/7a3ef342fe12625efb278dfa3f630edc to your computer and use it in GitHub Desktop.
Save BramDriesen/7a3ef342fe12625efb278dfa3f630edc to your computer and use it in GitHub Desktop.
Remove all images with an hash (Wordpress)
SELECT id, post_title
FROM wp_posts
WHERE post_type = 'attachment'
AND LENGTH(post_title) = 32
AND post_title not like '%.%'
SELECT *
FROM wp_postmeta
WHERE post_id in (
SELECT id
FROM wp_posts
WHERE post_type = 'attachment'
AND LENGTH(post_title) = 32
AND post_title not like '%.%'
)
DELETE
FROM wp_postmeta
WHERE post_id in (
SELECT id
FROM wp_posts
WHERE post_type = 'attachment'
AND LENGTH(post_title) = 32
AND post_title not like '%.%'
)
DELETE
FROM wp_posts
WHERE post_type = 'attachment'
AND LENGTH(post_title) = 32
AND post_title not like '%.%'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment