clean_object_term_cache

函数
clean_object_term_cache ( $object_ids, $object_type )
参数
  • (int|array) $object_ids Single or list of term object ID(s).
    Required:
  • (array|string) $object_type The taxonomy object type.
    Required:
相关
  • get_object_taxonomies()
定义位置
相关方法
get_object_term_cacheclean_term_cacheupdate_object_term_cacheclean_category_cacheclean_user_cache
引入
2.3.0
弃用
-

clean_object_term_cache: 这个函数清除了对象术语的缓存。对象术语是与文章、页面或自定义文章类型相关的术语或类别: 当这个函数被调用时,它清除了所有对象术语数据的缓存。

从缓存中删除术语的分类关系。

将删除包含术语`$object_id`的整个分类关系。术语ID必须存在于分类法`$object_type`中,才能进行删除。

function clean_object_term_cache( $object_ids, $object_type ) {
	global $_wp_suspend_cache_invalidation;

	if ( ! empty( $_wp_suspend_cache_invalidation ) ) {
		return;
	}

	if ( ! is_array( $object_ids ) ) {
		$object_ids = array( $object_ids );
	}

	$taxonomies = get_object_taxonomies( $object_type );

	foreach ( $taxonomies as $taxonomy ) {
		wp_cache_delete_multiple( $object_ids, "{$taxonomy}_relationships" );
	}

	wp_cache_delete( 'last_changed', 'terms' );

	/**
	 * Fires after the object term cache has been cleaned.
	 *
	 * @since 2.5.0
	 *
	 * @param array  $object_ids An array of object IDs.
	 * @param string $object_type Object type.
	 */
	do_action( 'clean_object_term_cache', $object_ids, $object_type );
}

常见问题

FAQs
查看更多 >