get_main_site_id

函式
get_main_site_id ( $network_id = null )
引數
  • (int) $network_id Optional. The ID of the network for which to get the main site. Defaults to the current network.
    Required:
    Default: null
返回值
  • (int) The ID of the main site.
定義位置
相關方法
get_main_network_idis_main_siteget_the_idget_cat_idget_media_item
引入
4.9.0
棄用
-

get_main_site_id函式用來檢索多站點安裝中的主站點的ID: 該函式可用於檢索主站點的站點資料或執行站點級操作。

獲得主要網站的ID。

function get_main_site_id( $network_id = null ) {
	if ( ! is_multisite() ) {
		return get_current_blog_id();
	}

	$network = get_network( $network_id );
	if ( ! $network ) {
		return 0;
	}

	return $network->site_id;
}

常見問題

FAQs
檢視更多 >