如何在WordPress上制作2个版本的作者页面

I want to make 2 different types of WordPress author profile. One is written in English and another is written in Japanese. To do this, I add a custom user field. For example, 'biography' for the English version and '経歴' for the Japanese version.

At admin > user panel, each author can register their info in both languages, then in the English version author page I display get_the_author_meta( 'biography_en', $userID );, and in the Japanese version author page I display get_the_author_meta( 'biography_ja', $userID );.

How could I connect a URL and 2 author page?

Currently, I display {root URL}/author/{username} for the English version. I want to display the Japanese version as {root URL}/author/{username}/ja. Is it possible?

1个回答

You can use author.php template for adding rule

if ( isset($_GET['lang']) && $_GET['lang']=='ja'){
 /*echo JA data*/
}else{
 /*echo EN data*/
}

It will be work for url like {root URL}/author/{username}?lang=ja

If you want '{root URL}/author/{username}/ja' need to use Rewrite API

drema2014
drema2014 我认为通过参数改变更好。
大约 3 年之前 回复
douliu3831
douliu3831 尼斯! 非常感谢你!
大约 3 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问