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 4 replies, has 2 voices.

Last updated by przemyslawD-3 1 week, 1 day ago.

Assigned support staff: Bobby.

Author Posts
October 1, 2019 at 9:42 am #4670407

przemyslawD-3

Hello,

I have an item on the page that I would like to display on only one language version (extendable slider with leasing offer - wpml1.jpg).

To show this link I put this code in the footer:

<script src="hidden link"></script>

In the other language versions I have translated this phrase into a comment (wpml2.jpg):

<!--Leaselink off-->

It works but only when I switch between languages. When I type the direct url of a specific language version, the slider still appears.

How can I fix it?

October 1, 2019 at 7:48 pm #4675125

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hi There,

The quickest and most simple way to do this is to use a WPML constant that stores the current
language that the site is being viewed in.

It is called ICL_LANGUAGE_CODE and you can see a bit of documentation on it here: https://wpml.org/documentation/support/wpml-coding-api/

An example code would be:

<?php
if (ICL_LANGUAGE_CODE == "fr") {
    //show the form in French
} elseif (ICL_LANGUAGE_CODE == "de") {
    //show the form in German
} else {
    //show the default form in English if English is the default language
}
?>

Please adjust the code with the correct language code and let me know your results, please.

October 3, 2019 at 10:33 am #4686837

przemyslawD-3

Hi,

thanks for your response. I don't know, but the way I described also started working (maybe some catches were causing the problem?) 🙂

One more question about Your solution. What exactly It should look like in that case? Something like this? Or it isn't so easy (sorry, i don't know php very much).

<?php
if (ICL_LANGUAGE_CODE == "pl") {
    <script type="text/javascript" src="<em><u>hidden link</u></em>"></script>
} else {
    <!--Leaselink off-->
}
?>
October 3, 2019 at 4:18 pm #4689789

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hi There,

the code looks good, there is no need for it to be more complicated 🙂

October 7, 2019 at 2:03 pm #4708193

przemyslawD-3

My issue is resolved now. Thank you!