get_blog_permalink

Get the permalink for a post on another blog.

Description

(string) get_blog_permalink( (int) $blog_id, (int) $post_id ); 

Returns (string)

The post's permalink

Parameters (2)

0. $blog_id (int)
ID of the source blog.
1. $post_id (int)
ID of the desired post.

Usage

  1. if ( !function_exists( 'get_blog_permalink' ) ) { 
  2. require_once ABSPATH . WPINC . '/ms-functions.php'; 
  3.  
  4. // ID of the source blog. 
  5. $blog_id = -1; 
  6.  
  7. // ID of the desired post. 
  8. $post_id = -1; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = get_blog_permalink($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_permalink( $blog_id, $post_id ) { 
  2. switch_to_blog( $blog_id ); 
  3. $link = get_permalink( $post_id ); 
  4.  
  5. return $link;