2016-01-26 49 views
0

我想要定義我的Wordpress網站標題(博客名稱)和標語(博客說明)。我是新來的,也不知道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 定義這個可能的話好心幫或給我其他的解決辦法。

+0

到目前爲止,你已經嘗試過了嗎?手冊或谷歌對你想要實現的內容有什麼看法? – St0fF

+0

我將根據地理位置設置標題和說明。 –

回答

0

我在主題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; 
} 

它是工作代碼。 謝謝

0

我不認爲你可以在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; 
} 
+0

我將上面的代碼添加到了我的主題的function.php中。但沒有什麼是變化。 –

+0

你期望看到改變?如果您對標題使用bloginfo('description')或標題爲bloginfo(),則會看到更改。 – timhysniu