WordPress 2.3.1本身TAG并不支持中文,键入中文TAG后无法正常使用TAG搜索,显示为ASCII乱码路径。使用Simple Tags可以为中文TAG生成英文缩略名,通过英文缩略名可以使用TAG搜索,但问题并没有解决,每次发表文章使用已经存在的TAG都会在数据库里新建相同名字但缩略名为ASCII乱码的TAG。
举个例子,文章A使用”测试”作为中文TAG,然后通过Simple Tags修改”测试”的缩略名为英文”test”,然后你可以通过”?tag=test”可以搜索所有使用”测试”作为TAG的文章。然后问题在于,如果此时你又新写了一篇文章需要加入到”测试”TAG集中,你在新文章上使用的”测试”TAG会在数据库里再次生成,并且带有ASCII乱码的缩略名,也就是和之前的”测试”TAG冗余了。如何解决这个问题呢?请看下边:
首先备份你的WordPress/wp-includes/rewrite.php文件,以防修改出错。然后打开rewrite.php寻找如下代码:
—————————————————————
function get_tag_permastruct() {
if (isset($this->tag_structure)) {
return $this->tag_structure;
}
if (empty($this->permalink_structure)) {
$this->tag_structure = ”;
return false;
}
if (empty($this->tag_base))
$this->tag_structure = $this->front . ‘tag/’;
else
$this->tag_structure = $this->tag_base . ‘/’;
$this->tag_structure .= ‘%tag%’;
return $this->tag_structure;
—————————————————————
将蓝色代码替换为:
—————————————————————
if (! empty($this->permalink_structure)) {
—————————————————————
收藏和分享: