I have a client that has a main site (www.) and an exact copy in a different language on a sub-domain (french.), completely done on their own, including translations. Right now, they have a simple link at the top that says “view site in English/French” that link to the respective domain – no URL path.
They want to make the link change to the other site but keep the URL path the same. For example:
**[www.]domain.com/url/something/**
(Click change to French, the link takes them to…)
**[french.]domain.com/url/something/**
I can’t for the life of me figure out how to achieve this. Can anyone help?
[ad_2]
Solution depends on how the translations work – is it just separate wordpress installations for each language or wordpress works in multisite mode.
If it is multisite – then you simply can use plugin like [Multisite Language Switcher]).
If not – then you need provide more info about setup.
If the URLs the same for each site, in your single.php template, you could just do a simple (on the eng site) french.domain.com/`<?php echo $post->post_name(); ?>` (not sure if this will also include parent pages. A job for you to figure out;))
If the URLs are different, you could create a custom field for your pages/posts, and that field contains the corresponding language’s URL.
If the urls are exactly the same minus the front subdomain then it would seem fairly simple. In PHP wherever the file is you’re trying to edit just grab the path to the requested URL that the person is visiting and add the subdomain in front
This should help –