get_blogaddress_by_id

函式
get_blogaddress_by_id ( $blog_id )
引數
  • (int) $blog_id Blog ID.
    Required:
返回值
  • (string) Full URL of the blog if found. Empty string if not.
定義位置
相關方法
get_blogaddress_by_domainget_blogaddress_by_nameget_metadata_by_midget_post_meta_by_idget_blog_list
引入
-
棄用
-

get_blogaddress_by_id: 這個函式根據一個部落格的ID來返回其URL。它把部落格的ID作為引數,並返回與該ID相關的部落格的URL。

獲得一個完整的部落格URL,給定一個部落格ID。

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

常見問題

FAQs
檢視更多 >