get_blog_post

函式
get_blog_post ( $blog_id, $post_id )
引數
  • (int) $blog_id ID of the blog.
    Required:
  • (int) $post_id ID of the post being looked for.
    Required:
返回值
  • (WP_Post|null) WP_Post object on success, null on failure
定義位置
相關方法
get_blog_listget_blog_countget_blog_optionget_blog_statusget_post
引入
-
棄用
-

get_blog_post:根據站點ID和站點ID或域/路徑組合從網路中的站點檢索文章。

從網路上的任何站點獲取一篇部落格文章。

這個函式與get_post()相似,只是它可以從網路上的任何站點獲取文章,而不僅僅是當前站點。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function get_blog_post( $blog_id, $post_id ) {
switch_to_blog( $blog_id );
$post = get_post( $post_id );
restore_current_blog();
return $post;
}
function get_blog_post( $blog_id, $post_id ) { switch_to_blog( $blog_id ); $post = get_post( $post_id ); restore_current_blog(); return $post; }
function get_blog_post( $blog_id, $post_id ) {
	switch_to_blog( $blog_id );
	$post = get_post( $post_id );
	restore_current_blog();

	return $post;
}

常見問題

FAQs
檢視更多 >