get_blog_post() WordPress Function

The get_blog_post() function is used to display a blog post on a WordPress site. This function takes two parameters: the post ID and the post title. The post ID is used to identify the blog post, and the post title is used to display the title of the blog post.

get_blog_post( int $blog_id, int $post_id ) #

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.


Top ↑

Parameters

$blog_id

(int)(Required)ID of the blog.

$post_id

(int)(Required)ID of the post being looked for.


Top ↑

Return

(WP_Post|null) WP_Post object on success, null on failure


Top ↑

Source

File: wp-includes/ms-functions.php

function get_blog_post( $blog_id, $post_id ) {
	switch_to_blog( $blog_id );
	$post = get_post( $post_id );
	restore_current_blog();

	return $post;
}


Top ↑

Changelog

Changelog
VersionDescription
MU (3.0.0)Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More