When encountered Chinese wordpress Categories,404 the perfect solution!

This problem is encountered a few years ago,Looking back now look,The original solution did some sloppy - because I overlooked an important factor,That's coding problems。

According to this article after solving approach actually works - provided that you have to click in the blog to be effective,But once you meet like this crawling connection:

http://www.logcg.com/%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80

Although after opening the browser address bar displays is still Chinese,But the Chinese has long nor that the Chinese。A direct result of encoding a different result is --404!

No wonder when the first reply to a comment it is not valid! Ha ha。

So exactly how to solve it? I think,I'm afraid the most perfect way to use the alias of the way,Categories in Chinese,But WordPress does offer the Alias ​​Options Category,You canSet the alias Pinyin,orEnglish shorthand,Even simply isEnglish wordsAlso possible,Such,It is compatible with all inside and outside friends。


 

 

I guess the question should be used for eachwordpressYou will encounter it? I actually have not found so long,Sweat ~

When wordpress encounterChinese Categorywhen,Will404,The classification into English and will be able to open,This is probably becauseStatic pagesCaused it。But take each category are British culture which in turn will make the reader feel dizzy looking at - who like birds ah ha ha

so,Or find another solution,I use this approach perfect solution,The main reference to theHere

The solution is simple,It is a "!" Issue,All right.,Let's start。

First, your blog space wp-includs folder below,turn uprewrite.phpfile,Then do some backup,We want to modify the content in the inside。

Then open already backed up rewrite.php,Find the following line at about 1000 local,Of course,Gray notes between the code you should ignore Oh。

function get_category_permastruct() {

return $this->get_extra_permastruct(‘category’);

}

function get_tag_permastruct() {
return $this->get_extra_permastruct(‘post_tag’);

}

function get_extra_permastruct($name) {
if ( empty($this->permalink_structure) )
return false;

if ( isset($this->extra_permastructs[$name]) )
return $this->extra_permastructs[$name][0];

return false;
}

 

Yes,Is if we want to modify ( empty($this->permalink_structure) )This line,In front of empty add an exclamation mark English,which is

if ( empty($this->permalink_structure) )

if ( !empty($this->permalink_structure) )

 

Then save it:)

Original article written by LogStudio:R0uter's Blog » When encountered Chinese wordpress Categories,404 the perfect solution!

Reproduced Please keep the source and description link:https://www.logcg.com/archives/146.html

About the Author

R0uter

The non-declaration,I have written articles are original,Reproduced, please indicate the link on this page and my name。

Comments

    1. You are right,But if it is already running for a long time blog,That again I do not think a small change of the project,Including a collection, etc. will receive the impact。Other than that,Some written in Chinese or classification quite nice ......
      =。After all =,Is a Chinese blog haha:)

      Of course,If this is a new blog,In this way a good plan is good!

Leave a Reply

Your email address will not be published. Required fields are marked *