这个Google Content Experiments installation 不适合我。I add the code in the header, but nothing is output.
因此,我已经将Google Analytics实验代码手动添加到标题中。唯一的问题是主题在网络站点之间共享。因此,我只想在当前URL={value}的条件下将代码插入头中。
我知道我可以用conditional tags, 但如果我使用is\\U页面,这可能会在另一个网站上意外触发。
我该怎么做?
这个Google Content Experiments installation 不适合我。I add the code in the header, but nothing is output.
因此,我已经将Google Analytics实验代码手动添加到标题中。唯一的问题是主题在网络站点之间共享。因此,我只想在当前URL={value}的条件下将代码插入头中。
我知道我可以用conditional tags, 但如果我使用is\\U页面,这可能会在另一个网站上意外触发。
我该怎么做?
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