A WordPress-centric search engine for devs and theme authors



get_blogaddress_by_id ›

Since3.0.0
Deprecatedn/a
get_blogaddress_by_id ( $blog_id )
Parameters:
  • (int) $blog_id Blog ID
    Required: Yes
Returns:
  • (string) Full URL of the blog if found. Empty string if not.
Defined at:
Codex:
Change Log:
  • MU

Get a full blog URL, given a blog id.



Source

function get_blogaddress_by_id( $blog_id ) {
	$bloginfo = get_site( (int) $blog_id );

	if ( empty( $bloginfo ) ) {
		return '';
	}

	$scheme = parse_url( $bloginfo->home, PHP_URL_SCHEME );
	$scheme = empty( $scheme ) ? 'http' : $scheme;

	return esc_url( $scheme . '://' . $bloginfo->domain . $bloginfo->path );
}