get_blogaddress_by_name() WordPress Function

The get_blogaddress_by_name() function is used to get a blog's address (URL) by its name.

get_blogaddress_by_name( string $blogname ) #

Get a full blog URL, given a blog name.


Parameters

$blogname

(string)(Required)The (subdomain or directory) name


Top ↑

Return

(string)


Top ↑

Source

File: wp-includes/ms-blogs.php

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 . '/' );
}


Top ↑

Changelog

Changelog
VersionDescription
MU (3.0.0)Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.