global $wp;
$current_url = add_query_arg( $wp->query_string, \'\', home_url( $wp->request ) );
$is_specific_network = stripos( $current_url, \'specific_domain_or_ip_address\' );
if( $is_specific_network !== false ) {
// do the task below
} else {
// do something else or leave it blank
}
注意:您需要替换上面的IP地址或特定域名以区分网络。
================或======================
<?php
$current_site = get_current_site();
$current_domain = $current_site->domain;
if( $current_domain == \'something\' ) {
// do something
}
?>
您可以使用返回的数据中的任何内容:
(object)
An object containing details of the site currently being viewed. Details are represented in the following public variables:
id
(integer) ID of the site currently being viewed.
domain
(string) Domain of the site currently being viewed.
path
(string) Path of the site currently being viewed.
site_name
(string) Title of the site currently being viewed.
参考:
http://codex.wordpress.org/WPMU_Functions/get_current_site