wp_update_term_count
函数
wp_update_term_count ( $terms, $taxonomy, $do_deferred = false )
- 参数
-
-
(int|array)
$terms
The term_taxonomy_id of the terms.- Required: 是
-
(string)
$taxonomy
The context of the term.- Required: 是
-
(bool)
$do_deferred
Whether to flush the deferred term counts too. Default false.- Required: 否
- Default: false
-
(int|array)
- 返回值
-
- (bool) If no terms will return false, and if successful will return true.
- 定义位置
-
-
wp-includes/taxonomy.php
, line 3446
-
wp-includes/taxonomy.php
- 引入
- 2.3.0
- 弃用
- –
更新分类法中的术语数量。
如果有一个分类法的回调,那么它将被调用以更新计数。
默认动作是计算有术语ID关系的术语数量。一旦完成,就会更新数据库。
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 );
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。


