On this page
wp_update_term_count_now( array $terms, string $taxonomy ): true
Performs term count update immediately.
Parameters
$termsarray Required-
The term_taxonomy_id of terms to update.
$taxonomystring Required-
The context of the term.
Return
true Always true when complete.
Source
File: wp-includes/taxonomy.php. View all references
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 ( 0 === strpos( $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.
_update_post_term_count( $terms, $taxonomy );
} else {
// Default count updater.
_update_generic_term_count( $terms, $taxonomy );
}
}
clean_term_cache( $terms, '', false );
return true;
}
Related
Uses
| Uses | Description |
|---|---|
| _update_post_term_count() wp-includes/taxonomy.php | Updates term count based on object types of the current taxonomy. |
| _update_generic_term_count() wp-includes/taxonomy.php | Updates term count based on number of objects. |
| clean_term_cache() wp-includes/taxonomy.php | Removes all of the term IDs from the cache. |
| get_taxonomy() wp-includes/taxonomy.php | Retrieves the taxonomy object of $taxonomy. |
Used By
| Used By | Description |
|---|---|
| wp_update_term_count() wp-includes/taxonomy.php | Updates the amount of terms in taxonomy. |
Changelog
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_update_term_count_now