Archived topic
Elements depending on language (with WPML)
19 replies · Started by Christoph on May 19, 2020
We are using Generate Press and WPML, for a website in spanish and english. We are using for each language a different domain:
Spanish: http://www.concepto3s.com
English: http://www.3hconcept.com
(1) Different Logo each language:
I tried with ELEMENTS a Hook for all the website, before logo and this code
<?php if ( ICL_LANGUAGE_CODE == 'en' ) { ?>
<img src="http://www.concepto3s.com/wp-content/uploads/2020/05/3hconcept-web.jpg" alt="" />
<?php } else { ?>
<img src="http://www.concepto3s.com/wp-content/uploads/2020/05/concepto3s-web.jpg" alt="" />
<?php } ?>
to show a different logo depending on the language (as I found in another Support Topic). But now, there is no logo shown, not in spanish, not in english.
(2) Would it be possible also to use a different FAVICON depending on the language? and
(3) Also using a different "Copyright Content" depending on the language?
Hi there,
Is it the same WordPress installation with two different domains?
What kind of logo setup are you using by default? Have you simply added it through Customize > Site Identity?
Hi, hello,
yes, the same WordPress installation with 2 domains. The WPML Tutorial:
https://wpml.org/tutorials/2016/04/use-wpml-different-domains-per-language/
Yes, by default the spanish logo by Customize > Site Identity.
Give this function a shot:
add_filter( 'generate_logo', function( $logo ) {
if ( ICL_LANGUAGE_CODE == 'en' ) {
return 'URL TO ENGLISH LOGO';
}
return $logo;
} );
Let me know :)
I am not sure, where and how to add this function.
Hi there,
this article explains how to add that PHP snippet:
Ok, now it shows this error:
Warning: Use of undefined constant CL_LANGUAGE_CODE - assumed 'CL_LANGUAGE_CODE' (this will throw an Error in a future version of PHP) in /var/www/web1780/html/wp-content/plugins/code-snippets/php/snippet-ops.php(446) : eval()'d code on line 2
Can you try the updated code?: https://generatepress.com/forums/topic/elements-depending-on-language-with-wpml/#post-1292891
Yes, this is the code I used.
Screenshot: https://drive.google.com/file/d/1U9QWbFtuclFayGa2UrykTjfvCWllUcDh/view?usp=drivesdk
I actually made a change to it - can you try the updated code?
Yes, this updated code works. Thanks!
You're welcome :)
Hello, Team!
I use this code:
add_filter( 'generate_logo', function( $logo ) {
if ( ICL_LANGUAGE_CODE == 'en' ) {
return 'URL TO ENGLISH LOGO';
}
return $logo;
} );
It works well for me. But i also have on my site logo on sticky menu - inside div with class="sticky-navigation-logo".
How to change logo on sticky menu?
I use GP Premium and WPML. My site will have three logos: russian, english and ukrainian.
Hi Serhii,
I'm not sure I fully understand what you mean.
To clarify:
Does the sticky menu logo have to be different w/ the static menu logo? Meaning it changes logo when you scroll down?
No, the sticky menu logo must be the same as the static menu logo.
Both types of logo should change depending on the language of the site.
The above code only works for the static menu logo.
I need some code that will change also sticky menu logo when switching site display language.