Created
April 27, 2010 14:51
-
-
Save tofumatt/380809 to your computer and use it in GitHub Desktop.
This file contains 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
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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.