我正在与以下问题作斗争:
$themeId = "";
$pathname = get_site_url();
if($pathname == \'domain2.com\'){
$themeId = "gold";}
else{
$themeId = "blue";}
wp_register_style(\'theme-skin\',THEMEURI . \'/css/\'.get_option($themeId).\'-style.css\', 3 , false, \'all\');
所以基本上,我有一个域名,
domain1.com. 它为wordpress使用蓝色主题,因此使用蓝色样式表:蓝色样式。css。
现在,我有了另一个域名,domain2。com,它使用完全相同的wordpress安装。所以我想在地址栏中获取当前url,并在此基础上更改颜色方案,blue 对于domain1.com 和gold 对于domain2.com.
但我上面的代码not 工作,它一直使用蓝色,无论访问哪个url-我在这里做错了什么?
谢谢
UPDATE: 原始默认代码
theme.css
if(get_option(THEMESLUG."_17_style")){
wp_register_style(\'theme-skin\',THEMEURI . \'/css/\'.get_option( THEMESLUG."_17_style").\'-style.css\', 3 , false, \'all\'); //dark skin
}
指定颜色的地方:
styling-options.phparray(
"name" => __("Theme Style",\'rt_theme_admin\'),
"desc" => __("Please choose a style for your theme.",\'rt_theme_admin\'),
"id" => THEMESLUG."_17_style",
"options" => array(
"blue" => "Blue Style",
"purple" => "Purple Style",
"orange" => "Orange Style",
"brown" => "Brown Style",
"rose" => "Rose Style",
"green" => "Green Style",
"grey" => "Grey Style",
"gold" => "Gold Style",
),
"default" => "blue",
"type" => "select"),
<小时>
SOLVED
大家好。我做了以下工作,现在它可以工作了:
if ( \'domain2.com\' === $_SERVER[\'HTTP_HOST\'] ) {
wp_register_style(\'theme-skin\',THEMEURI . \'/css/gold-style.css\', 3 , false, \'all\');
} else {
wp_register_style(\'theme-skin\',THEMEURI . \'/css/blue-style.css\', 3 , false, \'all\');
}