wordpress - wp_set_post_terms 没有更新 term_taxonomy 中的计数列

标签 wordpress

wp_set_post_terms($post_ID, 'my_term', 'my_taxonomy');

我的问题是,在 wp_term_taxonomy 中,计数为 0,但运行该行代码应该使其为 1。

我还添加了 register_taxonomy:

'update_count_callback' => '_update_post_term_count'

如果我手动将计数更改为 1,则会显示我的其他功能,因此除了计数列始终为 0 之外,一切都正确完成。

有谁知道为什么会这样吗?

最佳答案

如果它是附件的自定义分类法,您应该添加到register_taxonomy:

'update_count_callback' => '_update_generic_term_count'

关于wordpress - wp_set_post_terms 没有更新 term_taxonomy 中的计数列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9082370/

相关文章:

html - 更改 wordpress 帖子页面的背景

php - Wordpress 插件 - 按帖子数量对用户进行排名

html - 阻止 WordPress 在 CDATA 中包含脚本

jquery - 如何使用 jquery 在动画后更改 <li> 位置?

php - 使用 get_current_user_id() 的简单 IF 语句出现问题

css - 在 Wordpress 中使用谷歌字体

css - SASS 嵌套导致 IE 的特定选择器过多

html - 使用 CSS 更改 div 布局? (交替div)

php - 预定销售结束,但查看产品时可变产品似乎仍在销售 - Woocommerce

php - 使用 AM/PM 将字符串转换为 mysql 日期时间