为 WordPress 永久链接添加前缀
我正在构建一个插件来为 WordPress 添加多语言支持。
我需要能够将语言信息添加到 url,而标准(且合理)的方法是将语言代码作为前缀添加到路径中。
例如,网站上的英文页面可能位于 http://example.com/en/pagename/< /a>,而西班牙语页面可能位于 http://example.com/es/nombredepagina/。
为了做到这一点,有必要(或者更确切地说,是可取的,因为这也可以通过复杂的黑客来完成)修改 WordPress 永久链接结构,以便语言代码(最基本的形式由 2-3 个字母组成) ) 路径第一段中的将用于填充 lang
查询变量,而永久链接的其余部分仍将被解释为正常。
这可能吗?看起来应该是这样,但我对永久链接 API 一点也不熟悉,并且很难弄清楚它。谁能帮助我吗?
I am building a plugin to add multi-language support to WordPress.
I need to be able to add language info to the url, and the standard (and sensible) way of doing so is to add the language code as a prefix to the path.
So for example, an English page on the site might be at http://example.com/en/pagename/, whilst a Spanish page might be at http://example.com/es/nombredepagina/.
In order to do this, it is necessary (or rather, desirable, since this can also be done with complex hacks) to modify the WordPress permalink structure so that a language code (consisting, at its most basic form, of 2-3 letters) in the first segment of the path will be used to populate a lang
query var, whilst the rest of the permalink will still be interpreted as normal.
Is this possible? Sit seems that it should be, but I am not at all familiar with the permalink API and am having trouble figuring it out. Can anyone help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论