This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 1 reply, has 2 voices.

Last updated by Marcos Vinicios Barreto 8 months ago.

Assigned support staff: Marcos Vinicios Barreto.

Author Posts
October 3, 2019 at 4:03 pm #4689663


Tell us what you are trying to do?

I'm running WPML on separate domains, which means SEO is more important than usual. Specifically, it's not good for SEO when post links to post and the link description just says "Russian" - I'll end up with lots of links to translated pages, all wrongly associated with word "Russian" rather than with their actual contents.

What I would like is for Language Switcher above post to show flag of the available translation and then the name of the translated page.

So if I'm linking from
hidden link
to Russian page, URL is almost the same
hidden link, but language switcher should show Russian flag and give name fo the translated post: Пообщаемся в Telegram?

Likewise, if someone browses to
hidden link,

the language switcher should show British flag and post title - Up For A Telegram chat? - instead of British flag and words "Английский (English)".

Is there any documentation that you are following?
Can't find anything, but understand that it should be PHP function and not a Twig template.

Is there a similar example that we can see?
None that I can think of?

What is the link to your site?

hidden link
hidden link

October 3, 2019 at 9:13 pm #4691539

Marcos Vinicios Barreto

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Bahia (GMT-03:00)


Thank you for contacting WPML Support. Your request seems to be only possible with a bit of custom code, here a custom function I tested on my own:

function my_custom_post_languages(){
	$languages = icl_get_languages('skip_missing=1');
	if(1 < count($languages)){
	  echo __('This post is also available in: ', 'your-text-domain');
	  foreach($languages as $l){
		$mypost_id = url_to_postid( $l['url'] );
		$post = get_post( $mypost_id );
		if(!$l['active']) {
			echo '<a href="'.$l['url'].'">';
			if($l['country_flag_url']) {
				echo '<img src="'.$l['country_flag_url'].'" height="12" alt="'.$l['language_code'].'" width="18" />';
			echo $post->post_title;
			echo '</a>';

You can place the code above in the functions.php file of your child theme, then you can call the function (<?php my_custom_post_languages(); ?>) in your theme template files, usually in your page.php or single.php template files to show this custom language switcher.

Please, let me know if it helps to achieve your desired results, have a nice day.