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 3 risposte, has 2 voci.

Last updated by Rohan Sadanandan 2 mesi fa.

Assigned support staff: Rohan Sadanandan.

Autore Post
August 15, 2019 at 12:44 pm #4400829

albertoP-18

Hello,

I have a problem, I would like to display a php chat code only in English. Currently the main language of the site is Italian.

Thank you

August 16, 2019 at 9:26 am #4405685

Rohan Sadanandan
Supporter

Languages: Inglese (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello,

Thank you for contacting WPML Support.

You can use the "wpml_current_language" hook for getting the current language & write the code based on the condition. See the below sample code:

 
<?php
$my_current_lang = apply_filters('wpml_current_language', NULL);
if ($my_current_lang == "en") {
    // you chat code here
}
?>

You can refer the documentation for more details:
https://wpml.org/wpml-hook/wpml_current_language/

Thanks,
Rohan

August 16, 2019 at 11:24 am #4406031

albertoP-18

Hello,

seems not to work. The code is returned in the footer.

Thank you for support

August 16, 2019 at 12:56 pm #4406413

Rohan Sadanandan
Supporter

Languages: Inglese (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello,

You need to add the code in the template file where you need it to be displayed.

It seems that you are using some javascript code.
If so, please use the below sample code:

<?php
$my_current_lang = apply_filters('wpml_current_language', NULL);
if ($my_current_lang == "en") {
?>
   // you chat code here
<?php
}
?>

If it's still not working please share your code so that I can check whether you are adding it properly.

Thanks,
Rohan