On this page
get_blogaddress_by_name( string $blogname ): string
Get a full blog URL, given a blog name.
Parameters
$blognamestring Required-
The (subdomain or directory) name
Return
string
Source
File: wp-includes/ms-blogs.php. View all references
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 . '/' );
}
Related
Uses
| Uses | Description |
|---|---|
| is_subdomain_install() wp-includes/ms-load.php | Whether a subdomain configuration is enabled. |
| network_home_url() wp-includes/link-template.php | Retrieves the home URL for the current network. |
| esc_url() wp-includes/formatting.php | Checks and cleans a URL. |
Changelog
| Version | Description |
|---|---|
| MU (3.0.0) | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_blogaddress_by_name