Skip to content

Instantly share code, notes, and snippets.

@danielhomer
Created February 5, 2016 15:42
Show Gist options
  • Save danielhomer/892d45ad7cccaaf5b12a to your computer and use it in GitHub Desktop.
Save danielhomer/892d45ad7cccaaf5b12a to your computer and use it in GitHub Desktop.
cd /path/to/root
for id in $(wp site list --field=blog_id)
do
echo ${id}
mysql -h##HOST## -u##USER## -p##PASSWORD## -e "DELETE FROM wp_${id}_postmeta WHERE meta_key LIKE '_oembed_%' and meta_key NOT LIKE '_oembed_time_%' and meta_value NOT LIKE '%>' AND meta_value != '{{unknown}}';" ##DB_NAME##
echo Flushed dodgy OEmbeds from site ${id}
done
@kkranzo
Copy link

kkranzo commented Jul 12, 2016

Hey Daniel,

Do you know how I could convert this into a PHP script that I could create a daily cron job for so that my site could daily check for corrupt oembed caches?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment