wp_update_term_count_now
Perform term count update immediately.
Description
Parameters (2)
- 0. $terms (array)
- The term_taxonomy_id of terms to update.
- 1. $taxonomy (string)
- The context of the term.
Usage
if ( !function_exists( 'wp_update_term_count_now' ) ) { require_once ABSPATH . WPINC . '/taxonomy.php'; } // The term_taxonomy_id of terms to update. $terms = array(); // The context of the term. $taxonomy = ''; // NOTICE! Understand what this does before running. $result = wp_update_term_count_now($terms, $taxonomy);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/taxonomy.php
- 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 ( $object_types == array_filter( $object_types, 'post_type_exists' ) ) {
- // 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;
- }