admin管理员组文章数量:1391960
I need to dublicate all existing routes with several language codes:
/2020/03/11/Hello-world
/en/2020/03/11/Hello-world
/de/2020/03/11/Hello-world
/Hello-world-page
/en/Hello-world-page
/de/Hello-world-page
/...
/en/...
/de/...
Then I need to pre-handle all routes to check prefix exists and get as slug, then let related handlers do thier jobs.. I searched it many many times but never lucky to solve..
How to accomplish that? Thank you!
I need to dublicate all existing routes with several language codes:
/2020/03/11/Hello-world
/en/2020/03/11/Hello-world
/de/2020/03/11/Hello-world
/Hello-world-page
/en/Hello-world-page
/de/Hello-world-page
/...
/en/...
/de/...
Then I need to pre-handle all routes to check prefix exists and get as slug, then let related handlers do thier jobs.. I searched it many many times but never lucky to solve..
How to accomplish that? Thank you!
Share Improve this question edited Mar 11, 2020 at 18:31 Digerkam asked Mar 11, 2020 at 12:09 DigerkamDigerkam 2192 silver badges10 bronze badges 3- 1 Note that doing this would result in duplicated content which carries an SEO penalty. By default WP will redirect to the canonical page, and put the canonical URL in a meta tag to try and avoid this. Why would you want to duplicate all the URLs? – Tom J Nowell ♦ Commented Mar 11, 2020 at 12:42
- @TomJNowell Well, for language and localization codes.. /en/us/Hello-world for example.. Maybe no need to do it with routing, it would be great that get route before wp proccess, seperate codes, then let wp does it jobs. – Digerkam Commented Mar 11, 2020 at 12:53
- If you want to support URLs for multiple languages, that's the question you need to be asking. Focus on finding solutions for that specific problem, rather than the solution you've thought of, and you'll have an easier time. – Jacob Peattie Commented Mar 11, 2020 at 13:51
2 Answers
Reset to default 0add_filter('do_parse_request',function($state){
// Here you can change every request URL by $_SERVER['REQUEST_URI']
return $state;
},1,1);
Looks like you are trying to make the website Multilingual, so in order to achieve that, take a look at the Article on wordpress which says,
WordPress does not support a bilingual or multilingual blog out-of-the-box. There are however Plugins developed by the WordPress community which will allow you to create a multilingual blog easily. The free WPGlobus, Polylang, qTranslate-X, xili-language or Sublanguage plugins are installable on standalone WordPress sites. For multisite WordPress (one website per language), you can try Multisite Language Switcher, Zanto or Multilingual Press or purchase WPML.
You will get your routes having language code with some plugin mentioned above.
本文标签: routingHow to change all routes with language codes
版权声明:本文标题:routing - How to change all routes with language codes 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744677036a2619174.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论