Php SQL操作VS wp\u更新\u术语\u计数\u现在()相关问题
关于我不同分类法中的术语计数,我有一些奇怪的问题。这就是为什么我希望使用wp_update_term_count_now()来解决这个问题,但是这些函数似乎只关注特定的分类法,而不关注共享的分类法(在一些CPT中使用术语) 这是我的实际代码:Php SQL操作VS wp\u更新\u术语\u计数\u现在()相关问题,php,mysql,sql,wordpress,Php,Mysql,Sql,Wordpress,关于我不同分类法中的术语计数,我有一些奇怪的问题。这就是为什么我希望使用wp_update_term_count_now()来解决这个问题,但是这些函数似乎只关注特定的分类法,而不关注共享的分类法(在一些CPT中使用术语) 这是我的实际代码: $taxonomies = get_taxonomies(); foreach( $taxonomies as $taxonomy ) { //echo '<pre>'.$taxonomy.'</pre>'; $ar
$taxonomies = get_taxonomies();
foreach( $taxonomies as $taxonomy ) {
//echo '<pre>'.$taxonomy.'</pre>';
$args = array(
'fields' => 'ids'
);
$terms = get_terms( $taxonomy, $args );
if( is_array( $terms ) ) wp_update_term_count_now( $terms, $taxonomy );
此SQL检索每个已注册帖子类型中的计数以及所有自定义帖子类型的所有分类的所有术语,以便为每个术语显示适当的计数器
我的问题是:如何使用wp\u update\u term\u count\u now($terms$taxonomy)实现这一点?我在我的代码中没有看到任何错误,到目前为止也没有错误
谢谢你的帮助
UPDATE alt_15846_term_taxonomy tt
SET count =
(SELECT count(p.ID) FROM alt_15846_term_relationships tr
LEFT JOIN alt_15846_posts p
ON (p.ID = tr.object_id AND p.post_type = 'jeux-video' AND p.post_status = 'publish')
OR (p.ID = tr.object_id AND p.post_type = 'logiciels' AND p.post_status = 'publish')
OR (p.ID = tr.object_id AND p.post_type = 'ext-navigateurs' AND p.post_status = 'publish')
OR (p.ID = tr.object_id AND p.post_type = 'plugins-cms' AND p.post_status = 'publish')
OR (p.ID = tr.object_id AND p.post_type = 'sites-web' AND p.post_status = 'publish')
OR (p.ID = tr.object_id AND p.post_type = 'services-en-ligne' AND p.post_status = 'publish')
WHERE tr.term_taxonomy_id = tt.term_taxonomy_id
)