get_blog_post

Get a blog post from any site on the network.

Description

(WP_Post|null) get_blog_post( (int) $blog_id, (int) $post_id ); 

Returns (WP_Post|null)

WP_Post on success or null on failure

Parameters (2)

0. $blog_id (int)
ID of the blog.
1. $post_id (int)
ID of the post you're looking for.

Usage

  1. if ( !function_exists( 'get_blog_post' ) ) { 
  2. require_once ABSPATH . WPINC . '/ms-functions.php'; 
  3.  
  4. // ID of the blog. 
  5. $blog_id = -1; 
  6.  
  7. // ID of the post you're looking for. 
  8. $post_id = -1; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = get_blog_post($blog_id, $post_id); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/ms-functions.php  
  1. function get_blog_post( $blog_id, $post_id ) { 
  2. switch_to_blog( $blog_id ); 
  3. $post = get_post( $post_id ); 
  4.  
  5. return $post;