get_blogaddress_by_name

Get a full blog URL, given a blog name.

Description

(string) get_blogaddress_by_name( (string) $blogname ); 

Returns (string)

Parameters (1)

0. $blogname (string)
The (subdomain or directory) name

Usage

  1. if ( !function_exists( 'get_blogaddress_by_name' ) ) { 
  2. require_once ABSPATH . WPINC . '/ms-blogs.php'; 
  3.  
  4. // The (subdomain or directory) name 
  5. $blogname = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_blogaddress_by_name($blogname); 
  9.  

Defined (1)

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

/wp-includes/ms-blogs.php  
  1. function get_blogaddress_by_name( $blogname ) { 
  2. if ( is_subdomain_install() ) { 
  3. if ( $blogname == 'main' ) 
  4. $blogname = 'www'; 
  5. $url = rtrim( network_home_url(), '/' ); 
  6. if ( !empty( $blogname ) ) 
  7. $url = preg_replace( '|^([^\.]+://)|', "\${1}" . $blogname . '.', $url ); 
  8. } else { 
  9. $url = network_home_url( $blogname ); 
  10. return esc_url( $url . '/' );