update_term_cache

函式
update_term_cache ( $terms, $taxonomy = '' )
引數
  • (WP_Term[]) $terms Array of term objects to change.
    Required:
  • (string) $taxonomy Not used.
    Required:
    Default: (empty)
定義位置
相關方法
update_termmeta_cacheupdate_site_cacheupdate_user_cachesupdate_sitemeta_cacheupdate_category_cache
引入
2.3.0
棄用
-

update_term_cache: 這個函式更新分類學術語資料的快取。它通常在術語的資料被更新後被呼叫,例如當一個術語被新增或刪除時。

更新快取中的術語。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function update_term_cache( $terms, $taxonomy = '' ) {
$data = array();
foreach ( (array) $terms as $term ) {
// Create a copy in case the array was passed by reference.
$_term = clone $term;
// Object ID should not be cached.
unset( $_term->object_id );
$data[ $term->term_id ] = $_term;
}
wp_cache_add_multiple( $data, 'terms' );
}
function update_term_cache( $terms, $taxonomy = '' ) { $data = array(); foreach ( (array) $terms as $term ) { // Create a copy in case the array was passed by reference. $_term = clone $term; // Object ID should not be cached. unset( $_term->object_id ); $data[ $term->term_id ] = $_term; } wp_cache_add_multiple( $data, 'terms' ); }
function update_term_cache( $terms, $taxonomy = '' ) {
	$data = array();
	foreach ( (array) $terms as $term ) {
		// Create a copy in case the array was passed by reference.
		$_term = clone $term;

		// Object ID should not be cached.
		unset( $_term->object_id );

		$data[ $term->term_id ] = $_term;
	}
	wp_cache_add_multiple( $data, 'terms' );
}

常見問題

FAQs
檢視更多 >