WordPress博客底部
我在一个 WordPress 博客上工作,试图开发一个多语言系统。 每当用户单击他的语言按钮时,lang 查询参数就会添加到 url 中。
Ex. localhost/my-blog?lang=es
一切正常。重点是我有博客主菜单,其中包含指向使用 wordpress bloginfo('url '):
Ex. <a href="<?php bloginfo('url');?>/contact-us">contact us</a>
每当用户在主页选择其语言,然后单击“联系我们”时,
他都会收到此错误链接:
localhost/my-blog?lang=es/contact-us
你们使用哪种 WordPress 功能来处理此类事情?强
谢谢卢卡
>
im working on a wordpress blog tryin to develop a multilanguage system.
Whenever the user clicks on his language button the lang query parameter is added to the url
Ex. localhost/my-blog?lang=es
Everything works.The point is i have the blog main menu that has links to different sections of the site that are using the wordpress bloginfo('url') :
Ex. <a href="<?php bloginfo('url');?>/contact-us">contact us</a>
And whenever the user choose it's language at the home-page and then clicks on "contact us"
he receive this wrong link:
localhost/my-blog?lang=es/contact-us
which wordpress function you use guys for this kind of things?
thanks
Luca
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这种类型的 url 查询将来会给你带来麻烦,为什么不遵守使用会话值或基本 cookie 来存储用户的选择,
那么你可以简单地向你的functions.php文件添加一些代码来读取会话值或cookie,并返回翻译类型?
还有这个插件 xili-language
即:functions.php
代码非常粗糙,但你明白了..?
存储用户的选择,
检查该选择,
如果已设置,则使用该值作为网站上的语言首选项..?
否则就恢复默认..
I think this type of url query will get you into trouble in the future, why not conform to using either a session value or base cookie to store the users choice,
then that way you can simply add some code to your functions.php file to read the session value or cookie, and return the translation type?
there is also this plugin xili-language
ie: functions.php
the code is really rough, but you get the idea..?
store the users choice,
check for that choice,
if its been set then use that value as the language pref on the site..?
else just revert back to the default..