Cette page est également disponible en Français Français

If like me you do not have a site fully translated, but only a few posts, you certainly want to inform users that a particular post is available in another language.

I addressed the issue by writing the docs of my plugins. I starded writting them in English to make them accessible to the greatest number, I then thought it was a shame not to translate them into French! So I translated those articles, but I have not found a way to simply switch from French to English and vice versa. So I read Polylang documentation – the plugin that allowed me to make my multilingual site – and I found the elements I needed.

Here’s the function that you can use to detect if a translation exists for an post:

 

The function will automatically add a link to switch language at the top of the content if it is available in another language. In my case, I restricted the filter on the Article page type only.

If you’re not comfortable with CSS, here is the style that I use on b*web:

 

 

Brice Capobianco

WordPress addict and self-taught. I love to learn and to create, then to share…
Founder of b-website.com