wp_update_term_count_now() - WordPress 函数参考中文文档

返回介绍

wp_update_term_count_now()

发布于 2017-09-11 字数 2157 浏览 758 评论 0

wp_update_term_count_now( array $terms,  string $taxonomy )

Perform term count update immediately.


描述


参数

$terms

(array)
(Required)
The term_taxonomy_id of terms to update.

$taxonomy

(string)
(Required)
The context of the term.


返回值

(true) Always true when complete.


源代码

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

更新日志

Version 描述
2.5.0 Introduced.

相关函数

Uses

  • wp-includes/taxonomy.php:
    _update_post_term_count()
  • wp-includes/taxonomy.php:
    _update_generic_term_count()
  • wp-includes/taxonomy.php:
    clean_term_cache()
  • wp-includes/taxonomy.php:
    get_taxonomy()

Used By

  • wp-includes/taxonomy.php:
    wp_update_term_count()

User Contributed Notes

上一篇:wp_update_term_count()

下一篇:wp_update_theme()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!