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 thread is resolved. Here is a description of the problem and solution.

Problem:
How to translate URL in php template or how to translate link in template? For example this:

Solution:
To add different links for each language, you can add links in the php template like this:

<?php if(ICL_LANGUAGE_CODE == 'en'){ ?>
          		<a href="https://www.horizonhomes-samui.com/tag/awards/">...</a>
	<?php } elseif(ICL_LANGUAGE_CODE == 'fr'){ ?>
          		<a href="https://www.horizonhomes-samui.com/fr/tag/awards">...</a>
	<?php } ?>

And you also need to translate that Tag and its related Posts into different languages. Then the translated Tags will show the translated posts like the one you have: https://www.horizonhomes-samui.com/fr/tag/awards

Relevant Documentation:
https://wpml.org/documentation/support/wpml-coding-api/

This topic contains 2 replies, has 2 voices.

Last updated by alexanderA 1 year ago.

Assigned support staff: Noman.

Author Posts
October 6, 2018 at 5:23 am #2792478

alexanderA

Hello. My site is at hidden link I have used WPML to create a French translation of my site (hidden link).

My site has a particular PHP template that is used to add the header to the page. In this template I have added a link:

<a href="hidden link"></a>

On my English page, this link points to the English version of the 'awards' tag archive, as expected (see attached screenshot hh-link-en). Furthermore, when I open that page, it displays two English posts that I have marked with the "awards" tag (as expected). I have now translated those two English posts into French. When I open my French homepage, the link still points to the same English-language URL (see attached screenshot hh-link-fr). How can I ensure this link points to a URL that displays the French-language posts that have been marked with the 'award' tag?

I think I first need to ensure that there is a valid URL that displays these French-language posts--is that correct? The URL hidden link is valid, but it displays zero posts. Perhaps I need to first translate the 'awards' tag?

Thanks.

October 8, 2018 at 7:41 pm #2797190

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting WPML Support. To add different links for each language, you can add links in the php template like this:

<?php if(ICL_LANGUAGE_CODE == 'en'){ ?>
          		<a href="<em><u>hidden link</u></em>">...</a>
	<?php } elseif(ICL_LANGUAGE_CODE == 'fr'){ ?>
          		<a href="<em><u>hidden link</u></em>">...</a>
	<?php } ?>

-- Doc for more info:
https://wpml.org/documentation/support/wpml-coding-api/

And you also need to translate that Tag and its related Posts into different languages. Then the translated Tags will show the translated posts like the one you have: hidden link

Thank you

October 15, 2018 at 11:36 am #2817175

alexanderA

OK thanks. We can consider this resolved.