将根据对象数更新术语计数。

原型

_update_generic_term_count( array $terms, object $taxonomy )

描述

‘link_category’分类法的默认回调。

参数

$terms (array) (Required) 术语分类标识列表。

$taxonomy (object) (Required) 当前的分类对象的术语。

源文件

路径:wp-includes/taxonomy.php

<?php
...
function _update_generic_term_count( $terms, $taxonomy ) {
	global $wpdb;
	foreach ( (array) $terms as $term ) {
		$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term ) );
		/** This action is documented in wp-includes/taxonomy.php */
		do_action( 'edit_term_taxonomy', $term, $taxonomy->name );
		$wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
		/** This action is documented in wp-includes/taxonomy.php */
		do_action( 'edited_term_taxonomy', $term, $taxonomy->name );
	}
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/_update_generic_term_count/