Paramètres

$terms

(array) (Requis) Les ids term_taxonomy_id des termes à mettre à jour.

$taxonomy

(string) (Requis) Contexte du terme.

Retourne

(bool) True quand complété.

Structure de la fonction wp_update_term_count_now()

Définie dans le fichier wp-includes/taxonomy.php à la ligne 3250 :

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;
}

Fonctions utilisées par wp_update_term_count_now()

_update_post_term_count()

Met à jour le compte des termes basé sur les types d'objets de la taxonomie actuelle.

_update_generic_term_count()

Met à jour le compte des termes basé sur le nombre d'objets.

clean_term_cache()

Supprime tous les ids de terme du cache.

get_taxonomy()

Retourne l'objet d'une taxonomie en donnant son nom.

Où trouver la fonction wp_update_term_count_now() dans le CMS Wordpress

Sources

Codex Wordpress : wp_update_term_count_now()

Autres fonctions dans le même fichier : wp-includes/taxonomy.php

Retour