get_blogaddress_by_id() WP 3.0.0
Get a full blog URL, given a blog ID.
No Hooks.
Return
String. Full URL of the blog if found. Empty string if not.
Usage
get_blogaddress_by_id( $blog_id );
- $blog_id(int) (required)
- Blog ID.
Changelog
Since 3.0.0 | Introduced. |
Code of get_blogaddress_by_id() get blogaddress by id WP 5.6
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 );
}