get_blogaddress_by_id

Get a full blog URL, given a blog id.

Description

(string) get_blogaddress_by_id( (int) $blog_id ); 

Returns (string)

Full URL of the blog if found. Empty string if not.

Parameters (1)

0. $blog_id (int)
The blog id.

Usage

  1. if ( !function_exists( 'get_blogaddress_by_id' ) ) { 
  2. require_once ABSPATH . WPINC . '/ms-blogs.php'; 
  3.  
  4. // The blog id. 
  5. $blog_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_blogaddress_by_id($blog_id); 
  9.  

Defined (1)

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

/wp-includes/ms-blogs.php  
  1. function get_blogaddress_by_id( $blog_id ) { 
  2. $bloginfo = get_site( (int) $blog_id ); 
  3.  
  4. if ( empty( $bloginfo ) ) { 
  5. return ''; 
  6.  
  7. $scheme = parse_url( $bloginfo->home, PHP_URL_SCHEME ); 
  8. $scheme = empty( $scheme ) ? 'http' : $scheme; 
  9.  
  10. return esc_url( $scheme . '://' . $bloginfo->domain . $bloginfo->path );