动态WordPress博客名称和博客描述


Dynamic Wordpress Blog Name and Blog Description

我正在尝试定义我的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中定义它如果可能的话,请帮助或给我其他解决方案。

我在函数中添加了以下代码.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;
}

它是工作代码。谢谢

我认为你不能在wp-config.php中指定标题和标语。不过,您应该能够使用过滤器来更改标语和博客名称。在插件或主题函数中.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;
}