The get_blog_post() WordPress PHP function retrieves a blog post from any site on the network, not just the current site.
Usage
To use the get_blog_post() function, simply provide the blog ID and post ID as arguments:
$post = get_blog_post(3, 6);
Parameters
- $blog_id (int) – Required. ID of the blog.
- $post_id (int) – Required. ID of the post being looked for.
More information
See WordPress Developer Resources: get_blog_post()
Examples
Display post title
Get the post with ID 6 from site 3 and display its title:
$post_6 = get_blog_post(3, 6);
if ($post_6) {
echo $post_6->post_title;
}
Display post content
Get the post with ID 12 from site 5 and display its content:
$post_12 = get_blog_post(5, 12);
if ($post_12) {
echo $post_12->post_content;
}
Display post author
Get the post with ID 8 from site 2 and display its author:
$post_8 = get_blog_post(2, 8);
if ($post_8) {
$author = get_userdata($post_8->post_author);
echo $author->display_name;
}
Display post date
Get the post with ID 20 from site 4 and display its publication date:
$post_20 = get_blog_post(4, 20);
if ($post_20) {
echo $post_20->post_date;
}
Display post permalink
Get the post with ID 15 from site 6 and display its permalink:
$post_15 = get_blog_post(6, 15);
if ($post_15) {
$permalink = get_permalink($post_15);
echo $permalink;
}