Last active
March 21, 2023 16:26
-
-
Save zevilz/b4f61b0ab82f3b6f146db89bc7dc1000 to your computer and use it in GitHub Desktop.
Remove old WP attachments
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
#!/bin/bash | |
while true; do | |
POSTS=$(wp db query 'SELECT ID FROM wp_posts WHERE post_type="attachment" AND post_date < "2022-06-05" LIMIT 10000;' --skip-column-names | paste -s -d ' ' -) | |
if ! [ -z "$POSTS" ]; then | |
wp post delete $POSTS --force | |
else | |
exit 0 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment