Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tofumatt/380809 to your computer and use it in GitHub Desktop.
Save tofumatt/380809 to your computer and use it in GitHub Desktop.
UPDATE wp_term_taxonomy tax
LEFT JOIN
(SELECT term_taxonomy_id as relid, count(*) as cnt FROM wp_term_relationships GROUP BY relid) rel
ON tax.term_taxonomy_id = rel.relid
SET tax.count = rel.cnt
WHERE tax.count != rel.cnt;
@tofumatt
Copy link
Author

This is really hackish and doesn't support private/disabled posts, etc. I'm not sure if it should, but it works for the very specific need I had. I couldn't find a core function or plugin that rebuild the denormalized data after doing an out-of-WordPress DB import. Weird.

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