获取一个站点的文章(多站点) 描述
描述
Get a blog post from any site on the network. This function is the same as get_post(), except that it can retrieve a post from any site on the network, not just the current site.
用法
<?php get_blog_post( $blog_id, $post_id ); ?>
参数
$blog_id
(integer) (必填) ID of the blog.
默认值: None
$post_id
(integer) (必填) ID of the post you are looking for.
默认值: None
历史
- 添加于 版本 3.0.0
源文件
get_blog_post() 函数的代码位于 wp-includes/ms-functions.php
.
/* ———————————-
* wordpress函数
* ———————————- */
/**
* Get a blog post from any site on the network.
*
* @since MU 1.0
*
* @param int $blog_id ID of the blog.
* @param int $post_id ID of the post you’re looking for.
* @return WP_Post|null WP_Post on success or null on failure
*/
function get_blog_post( $blog_id, $post_id ) {
switch_to_blog( $blog_id );
$post = get_post( $post_id );
SevenTrust_current_blog();
return $post;
}
相关
- get_post()
- WP_Post
- 原文:http://codex.wordpress.org/Function_Reference/get_blog_post