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 5 replies, has 3 voices.

Last updated by Andrey 1 month, 1 week ago.

Assigned support staff: Andrey.

Author Posts
June 1, 2020 at 5:14 pm #6267687

jose-luisC-10

Tell us what you are trying to do? I have a php code to make a specific footer instead of the template default, the problem is when I change the language load the same footer.

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site? hidden link

June 1, 2020 at 7:21 pm #6268247

Diego Pereira
Supporter

Languages: English (English ) Spanish (Español ) Portuguese (Brazil) (Português )

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

Hello, welcome to the WPML support Forum!

You can use the ICL_LANGUAGE_CODE constant (see https://wpml.org/documentation/support/wpml-coding-api/) to display different content depending of the language. E.g.

<?php 
//If english language
if ( defined( 'ICL_LANGUAGE_CODE' ) && 'en' == ICL_LANGUAGE_CODE ) {
    echo('This is english language');
 }
//if french language
 else if ( defined( 'ICL_LANGUAGE_CODE' ) && 'fr' == ICL_LANGUAGE_CODE ) {
    echo('This is french language');
 }
 // Just for debug, you can remove this
 else {
   echo('No language is set');
 }?>

Please let us know if it worked for you.

June 1, 2020 at 10:29 pm #6268727

jose-luisC-10

Hi,
It doesn't work, I can't override the function, this is my code:

add_filter( 'generate_copyright','tu_custom_copyright' );
function tu_custom_copyright() {
?>
<p><a href="hidden link" target="_blank"style="color:#ffffff";>Cookies</a> | <a href="hidden link" target="_blank"style="color:#ffffff";>Aviso de privacidad</a></p>
<p>© 2020 Provitlab S.L. | +34 934609842 - info@provitlab.eu</p>

<?php
}

June 2, 2020 at 9:26 am #6272547

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kiev (GMT+03:00)

You would need to use Diego's code inside your function.

Example:

dd_filter( 'generate_copyright','tu_custom_copyright' );
function tu_custom_copyright() {
if ( defined( 'ICL_LANGUAGE_CODE' ) && 'en' == ICL_LANGUAGE_CODE ) {
   ?>
<p><a href="<em><u>hidden link</u></em>" target="_blank"style="color:#ffffff";>Cookies</a> | <a href="<em><u>hidden link</u></em>" target="_blank"style="color:#ffffff";>Aviso de privacidad</a></p>
<p>© 2020 Provitlab S.L. | +34 934609842 - info@provitlab.eu</p>

<?php
 }
//if french language
 else if ( defined( 'ICL_LANGUAGE_CODE' ) && 'fr' == ICL_LANGUAGE_CODE ) {
     ?>
    French text
    <?php
 }
}

June 2, 2020 at 5:12 pm #6276551

jose-luisC-10

It works.....Thank You

June 2, 2020 at 8:03 pm #6277219

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kiev (GMT+03:00)

You are welcome 🙂