On this page
get_blog_post( int $blog_id, int $post_id ): WP_Post|null
Gets a blog post from any site on the network.
Description
This function is similar to get_post() , except that it can retrieve a post from any site on the network, not just the current site.
Parameters
$blog_idint Required-
ID of the blog.
$post_idint Required-
ID of the post being looked for.
Return
Source
File: wp-includes/ms-functions.php. View all references
function get_blog_post( $blog_id, $post_id ) {
switch_to_blog( $blog_id );
$post = get_post( $post_id );
restore_current_blog();
return $post;
}
Related
Uses
| Uses | Description |
|---|---|
| restore_current_blog() wp-includes/ms-blogs.php | Restore the current blog, after calling switch_to_blog() . |
| switch_to_blog() wp-includes/ms-blogs.php | Switch the current blog. |
| get_post() wp-includes/post.php | Retrieves post data given a post ID or post object. |
Changelog
| Version | Description |
|---|---|
| MU (3.0.0) | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_blog_post