update_post_author_caches

函式
update_post_author_caches ( $posts )
引數
  • (WP_Post[]) $posts Array of post objects.
    Required:
定義位置
相關方法
update_post_parent_cachesupdate_post_cachesupdate_post_cacheupdate_postmeta_cacheupdate_post_thumbnail_cache
引入
6.1.0
棄用
-

update_post_author_caches: 這個函式更新一個文章的作者的快取。它需要一個引數:$post_id。$post_id是需要更新作者快取的文章的ID。

為文章物件的列表更新文章作者使用者快取。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function update_post_author_caches( $posts ) {
$author_ids = wp_list_pluck( $posts, 'post_author' );
$author_ids = array_map( 'absint', $author_ids );
$author_ids = array_unique( array_filter( $author_ids ) );
cache_users( $author_ids );
}
function update_post_author_caches( $posts ) { $author_ids = wp_list_pluck( $posts, 'post_author' ); $author_ids = array_map( 'absint', $author_ids ); $author_ids = array_unique( array_filter( $author_ids ) ); cache_users( $author_ids ); }
function update_post_author_caches( $posts ) {
	$author_ids = wp_list_pluck( $posts, 'post_author' );
	$author_ids = array_map( 'absint', $author_ids );
	$author_ids = array_unique( array_filter( $author_ids ) );

	cache_users( $author_ids );
}

常見問題

FAQs
檢視更多 >