WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using WPML to translate a website. The only major issue I have with WPML is that you cannot have a page in different languages with the same slug.

Therefore www.example.com/contact/ and www.example.com/fr/contact/ is not possible.

To get around this I was thinking of saving the french version as www.example.com/fr/contact-fr/ in the database but have this transparent to the user. To do that I was thinking of manipulating the URL so the the user sees www.example.com/fr/contact/ but Wordpress handles it as if the page were www.example.com/fr/contact-fr/

Is it possible to do this with a function or rewrites?

share|improve this question
this is not a flaw of WPML as you make it sound, WordPress just doesn't allow it. Try making 2 posts/pages with the exact same slug and WordPress will automatically put -2 behind the second one... – Piet Sep 16 '11 at 7:56
yes true but after all the posts they have in their forum I would have thought WPML would offer a workaround or solution (without breaking any Wordpress 'rules') – Matthew Xerri Sep 16 '11 at 10:16
that's basically asking of WPML to develop their own fork of WordPress, now isn't it? – Piet Sep 16 '11 at 12:10
not really no. just a solution in the plugin or a patch users can test. – Matthew Xerri Sep 19 '11 at 15:24
up vote 1 down vote accepted

i'm not familiair with WPML, but i do know that qTranslate has the feature your describing.

share|improve this answer
yes but qTranslate is the complete opposite. You can never change the URL so its a bit limiting as well. Plus the developer of qTranslate hasn't posted anything in the forum in months. WPML offers support and that is important – Matthew Xerri Sep 12 '11 at 10:24
allright. but if from the two plugins, the free one has the feature i was looking for, the choice would be easy. i've made dozens of WP sites with qTranslate and i never had a problem that needed to be answered by the developer. – DeanAlexRainier Sep 21 '11 at 14:03
Since no official solution exists yet, I switched to qTranslate. Only drawback is that I have to have the same URL for each language for every page. There is no flexibility there but it's not that big of a deal. – Matthew Xerri Sep 26 '11 at 12:30

I don't know how WPML impacts the handling of the rewrite rules, but it should be possible to create a rewrite rule that constructs the pagename from two different parts of the rewrite pattern. From the top of my head:

add_rewrite_rule('(..)/(.+)', 'index.php?pagename=$matches[2]-$matches[1]');

If you are going to do avanced stuff with rewrite rules you might want to install my Rewrite Analyzer plugin to try stuff out.

share|improve this answer
not sure I understand you. I just want to hide -fr from the url so www.example.com/fr/contact-fr/ looks like www.example.com/fr/contact/ – Matthew Xerri Sep 12 '11 at 12:26

It will be easier to become a bit more creative with titles/slugs.

Also keep in mind that title and slug do not necessarily need to be the same.

So the title of the French contact page can still be "Contact" and then the slug can become "contactez-nous".

share|improve this answer
The problem is when it comes to product names. A product name is the same in any language. – Matthew Xerri Sep 16 '11 at 10:16
have a look at nzihelmets.co how I have solved it there. in other words with products the only solution is to use pages and child pages... – Piet Sep 16 '11 at 12:04
thats a good idea but we already have urls in place where products are not childs of "/product/" and we do not want to redirect everything. Plus with regards to SEO I think "/products/" is not necessary. – Matthew Xerri Sep 19 '11 at 15:26
then you'd better check whether the solution of @Jan Fabry works... – Piet Sep 20 '11 at 14:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.