我试图定义我的Wordpress网站标题(博客名称)和口号(博客描述)。我是新来的,也不知道Wordpress的编码。
if ($country_code=="UK") {
define('WP_BLOGNAME', 'FOR UK');
define('WP_BLOGDESCRIPTION', 'UK');
}
else if ($country_code=="AU") {
define('WP_BLOGNAME', 'FOR Australia');
define('WP_BLOGDESCRIPTION', 'Australia');
}我想在wp_config.php中定义这一点,如果可能的话,请帮助或者给我其他的解决方案。
发布于 2016-01-27 00:24:22
我在主题的function.php文件中添加了下面的代码,并更改了博客名称和博客描述。
add_filter( 'option_blogdescription', 'mytheme_bloginfo', 10, 1 );
function mytheme_bloginfo( $text )
{
$country_code = ...;
if ($country_code=="UK") {
$text = "UK Description";
} else if ($country_code=="AU") {
$text = "AU Description";
}
return $text;
}
add_filter( 'option_blogname', 'mytheme_bloginfo_name', 10, 2);
function mytheme_bloginfo_name( $text )
{
$country_code = ...;
if ($country_code=="UK") {
$text = "United Kingdom";
} else if ($country_code=="AU") {
$text = "Australia";
}
return $text;
}这是工作密码。谢谢
发布于 2016-01-26 23:04:50
我认为您无法在wp-config.php中指定标题和标签行。不过,您应该能够使用过滤器来更改标签行和博客名。在插件或主题functions.php中,您可以添加以下内容:
add_filter( 'bloginfo', 'mytheme_bloginfo', 10, 2 );
function mytheme_bloginfo( $text, $show )
{
$country_code = ...
if ($show == 'description') {
if ($country_code=="UK") {
$text = "UK Description";
} else {
$text = "AU Description";
}
}
else {
if ($country_code=="UK") {
$text = "UK Title";
} else {
$text = "AU Title";
}
}
return $text;
}https://stackoverflow.com/questions/35025308
复制相似问题