get_blog_post

The timeline below displays how wordpress function get_blog_post has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.5

/**
 * Gets a blog post from any site on the network.
 *
 * 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.
 *
 * @since MU (3.0.0)
 *
 * @param int $blog_id ID of the blog.
 * @param int $post_id ID of the post being looked for.
 * @return WP_Post|null WP_Post object on success, null on failure
 */
function get_blog_post($blog_id, $post_id)
{
    switch_to_blog($blog_id);
    $post = get_post($post_id);
    restore_current_blog();
    return $post;
}

WordPress Version: 5.4

/**
 * Get a blog post from any site on the network.
 *
 * @since MU (3.0.0)
 *
 * @param int $blog_id ID of the blog.
 * @param int $post_id ID of the post being looked 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);
    restore_current_blog();
    return $post;
}

WordPress Version: 4.9

/**
 * Get a blog post from any site on the network.
 *
 * @since MU (3.0.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);
    restore_current_blog();
    return $post;
}

WordPress Version: 3.7

/**
 * 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);
    restore_current_blog();
    return $post;
}