多语言 WordPress 网站,每种语言都有自己的域名
目标是拥有一个具有多种语言版本的 WordPress 安装,这些版本共享媒体库(图像...)、用户帐户等,但也可以在自己的二级域上工作,所以我有 website.com 和 website.cc 和 website.de类似,但我不需要管理三个不同的 WordPress。
我想使用一些 DNS 魔法应该可以做到这一点,但我无法通过谷歌搜索任何方法来实现这一点。有人可以帮忙吗?
The goal is to have one wordpress instalation with varius language versions which share media library (images...), user accounts etc. but also work on their own second level domains so I have website.com and website.cc and website.de and similar but I dont need to manage three different wordpresses.
I guess that should be possible to do using some DNS magic but I havent been able to google any how-to to achieve that. Can someone help please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最近在一个网站上做到了这一点。通过使用 Plesk 中的域别名,所有所需的域都指向同一个位置。
在 wp-config.php 中,我使用以下 switch 语句检查了从哪个域请求页面。
然后,我设置 WP_SITEURL 和 WP_HOME 等内容,并定义可在 switch 语句中的主题内使用的语言。
我们使用自定义字段来允许管理员输入不同的语言,然后在functions.php中添加内容过滤器,以根据wp-config.php中定义的语言在前端切换这些内容。
可能有更好的方法来做到这一点,但这是我在 WordPress 的几个版本中想出的方法。
I have done this recently with a site. All of the domains required were pointed to the same place by using Domain Aliases in Plesk.
In the wp-config.php I checked to see which domain the page was being requested from by using the following a switch statement.
I then set things like WP_SITEURL and WP_HOME as well as defining a LANGUAGE which could be used within the theme within the switch statement.
We used custom fields to allow admins to enter different languages and then added a content filter into functions.php to switch these on the frontend based on the language defined in the wp-config.php.
There may be better ways to do this but this is what I came up with a few versions of WordPress back.