Last active
March 16, 2021 13:26
-
-
Save IlanVivanco/4f4a96488addaff4b0fe5b9f599fbe60 to your computer and use it in GitHub Desktop.
Update Post Count on Taxonomies
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 | |
SET | |
count = ( | |
SELECT | |
COUNT(*) | |
FROM | |
wp_term_relationships rel | |
LEFT JOIN wp_posts po ON (po.ID = rel.object_id) | |
WHERE | |
rel.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id | |
AND wp_term_taxonomy.taxonomy NOT IN ('link_category') | |
AND po.post_status IN ('publish', 'future') | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment