get_blogaddress_by_name()WP 3.0.0

Gets a full site URL, given a site name.

No Hooks.

Return

String.

Usage

get_blogaddress_by_name( $blogname );
$blogname(string) (required)
Name of the subdomain or directory.

Changelog

Since 3.0.0 Introduced.

get_blogaddress_by_name() code WP 6.4.3

function get_blogaddress_by_name( $blogname ) {
	if ( is_subdomain_install() ) {
		if ( 'main' === $blogname ) {
			$blogname = 'www';
		}
		$url = rtrim( network_home_url(), '/' );
		if ( ! empty( $blogname ) ) {
			$url = preg_replace( '|^([^\.]+://)|', '${1}' . $blogname . '.', $url );
		}
	} else {
		$url = network_home_url( $blogname );
	}
	return esc_url( $url . '/' );
}