wp_update_term_count_now( array $terms, string $taxonomy ): true

In this article

Performs term count update immediately.

Parameters

$termsarrayrequired
The term_taxonomy_id of terms to update.
$taxonomystringrequired
The context of the term.

Return

true Always true when complete.

Source

}

/**
 * Performs term count update immediately.
 *
 * @since 2.5.0
 *
 * @param array  $terms    The term_taxonomy_id of terms to update.
 * @param string $taxonomy The context of the term.
 * @return true Always true when complete.
 */
function wp_update_term_count_now( $terms, $taxonomy ) {
	$terms = array_map( 'intval', $terms );

	$taxonomy = get_taxonomy( $taxonomy );
	if ( ! empty( $taxonomy->update_count_callback ) ) {
		call_user_func( $taxonomy->update_count_callback, $terms, $taxonomy );
	} else {
		$object_types = (array) $taxonomy->object_type;
		foreach ( $object_types as &$object_type ) {
			if ( str_starts_with( $object_type, 'attachment:' ) ) {
				list( $object_type ) = explode( ':', $object_type );
			}
		}

		if ( array_filter( $object_types, 'post_type_exists' ) == $object_types ) {
			// Only post types are attached to this taxonomy.

Changelog

VersionDescription
2.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.