clean_taxonomy_cache

函式
clean_taxonomy_cache ( $taxonomy )
引數
  • (string) $taxonomy Taxonomy slug.
    Required:
定義位置
相關方法
clean_term_cacheclean_bookmark_cacheclean_category_cacheclean_page_cacheclean_network_cache
引入
4.9.0
棄用
-

clean_taxonomy_cache: 這個函式清除了分類學的快取。分類法是用來將文章和其他型別的內容分組的: 當這個函式被呼叫時,它清除了所有分類學資料的快取。

清理分類法的快取。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function clean_taxonomy_cache( $taxonomy ) {
wp_cache_delete( 'all_ids', $taxonomy );
wp_cache_delete( 'get', $taxonomy );
wp_cache_delete( 'last_changed', 'terms' );
// Regenerate cached hierarchy.
delete_option( "{$taxonomy}_children" );
_get_term_hierarchy( $taxonomy );
/**
* Fires after a taxonomy's caches have been cleaned.
*
* @since 4.9.0
*
* @param string $taxonomy Taxonomy slug.
*/
do_action( 'clean_taxonomy_cache', $taxonomy );
}
function clean_taxonomy_cache( $taxonomy ) { wp_cache_delete( 'all_ids', $taxonomy ); wp_cache_delete( 'get', $taxonomy ); wp_cache_delete( 'last_changed', 'terms' ); // Regenerate cached hierarchy. delete_option( "{$taxonomy}_children" ); _get_term_hierarchy( $taxonomy ); /** * Fires after a taxonomy's caches have been cleaned. * * @since 4.9.0 * * @param string $taxonomy Taxonomy slug. */ do_action( 'clean_taxonomy_cache', $taxonomy ); }
function clean_taxonomy_cache( $taxonomy ) {
	wp_cache_delete( 'all_ids', $taxonomy );
	wp_cache_delete( 'get', $taxonomy );
	wp_cache_delete( 'last_changed', 'terms' );

	// Regenerate cached hierarchy.
	delete_option( "{$taxonomy}_children" );
	_get_term_hierarchy( $taxonomy );

	/**
	 * Fires after a taxonomy's caches have been cleaned.
	 *
	 * @since 4.9.0
	 *
	 * @param string $taxonomy Taxonomy slug.
	 */
	do_action( 'clean_taxonomy_cache', $taxonomy );
}

常見問題

FAQs
檢視更多 >