W3cubDocs

/WordPress

_update_generic_term_count( int[] $terms, WP_Taxonomy $taxonomy )

Will update term count based on number of objects.

Description

Default callback for the ‘link_category’ taxonomy.

Parameters

$terms

(int[]) (Required) List of term taxonomy IDs.

$taxonomy

(WP_Taxonomy) (Required) Current taxonomy object of terms.

Source

File: wp-includes/taxonomy.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 );
	}
}

Changelog

Version Description
3.3.0 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/_update_generic_term_count