Created
September 17, 2015 09:35
-
-
Save mafsdisseny/a6a8ffb1e730d111615f to your computer and use it in GitHub Desktop.
Wordpress, Update the count parameter for a taxonomy, after data migration. In this case, only specify the post type name, and the associated taxonomies will be updated.
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 tt | |
SET count = | |
(SELECT count(p.ID) FROM wp_term_relationships tr | |
LEFT JOIN wp_posts p | |
ON (p.ID = tr.object_id AND p.post_type = 'post_type_name' AND p.post_status = 'publish') | |
WHERE tr.term_taxonomy_id = tt.term_taxonomy_id | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment