wp_update_term_count()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
wp_update_term_count( int|array $terms, string $taxonomy, bool $do_deferred = false ): bool
Описание
Если для таксономии задана функция обратного вызова, то она будет вызвана для обновления счётчика.
Действие по умолчанию — подсчитать количество терминов, связанных с данным ID термина. После этого база данных обновляется.
Оригинал (английский)
If there is a taxonomy callback applied, then it will be called for updating the count.
The default action is to count what the amount of terms have the relationship of term ID. Once that is done, then update the database.
Параметры
$terms
int|array
обязательный
$taxonomy
string
обязательный
$do_deferred
bool
необязательный
= false
Возвращаемое значение
bool
Исходный код
wp-includes/taxonomy.php:3545
function wp_update_term_count( $terms, $taxonomy, $do_deferred = false ) {
static $_deferred = array();
if ( $do_deferred ) {
foreach ( (array) array_keys( $_deferred ) as $tax ) {
wp_update_term_count_now( $_deferred[ $tax ], $tax );
unset( $_deferred[ $tax ] );
}
}
if ( empty( $terms ) ) {
return false;
}
if ( ! is_array( $terms ) ) {
$terms = array( $terms );
}
if ( wp_defer_term_counting() ) {
if ( ! isset( $_deferred[ $taxonomy ] ) ) {
$_deferred[ $taxonomy ] = array();
}
$_deferred[ $taxonomy ] = array_unique( array_merge( $_deferred[ $taxonomy ], $terms ) );
return true;
}
return wp_update_term_count_now( $terms, $taxonomy );
}
История изменений
| Версия | Описание |
|---|---|
| 2.3.0 | Introduced. |

