get_blogaddress_by_id() WordPress Function

The get_blogaddress_by_id() function is used to get the blog address for a given blog id. This is useful for retrieving the address of a remote blog.

get_blogaddress_by_id( int $blog_id ) #

Get a full blog URL, given a blog ID.


Parameters

$blog_id

(int)(Required)Blog ID.


Top ↑

Return

(string) Full URL of the blog if found. Empty string if not.


Top ↑

Source

File: wp-includes/ms-blogs.php

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 );
}


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.