有时,通过MySQL直接处理了WordPress的标签关联信息,会造成后台的标签云Tag数量统计异常的情况发生。

那么,WordPress如何更新Tag标签云的统计数据呢?

方法很简单,一段SQL搞定:

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')
)

参考资料:How to update WordPress taxonomies(categories/tags)’ count field after bulk import/delete



与《WordPress如何更新Tag标签云的统计》相关的博文:

留言