Archived topic
Change logo for each language - with polylang
13 replies · Started by Collectif WEB on May 24, 2017
Hey there!
I'd like to get different logos for the french and english version of my website.
I use Polylang.
What can I do to do that?
Thanks a lot for your help
Does Polylang have a conditional we can use to check the current language?
I found this function in WP, but not sure if it's compatible with Polylang: get_locale()
So in GP Hooks, you could do this in the Before Header Content hook:
<?php if ( 'en_GB' == get_locale() ) { ?>
<img src="URL TO en_GB logo" />
<?php } elseif ( 'fr_FR' == get_locale() ) { ?>
<img src="URL TO fr_FR logo" />
<?php } ?>
Thanks a lot for your help.
This is the conditional we need to use.
but the result wasn't that good. :P
https://ibb.co/j4GTfv
It added the logo :/
Did I miss something?
Thanks again
Did you check the "Execute PHP" checkbox?
I did and i unchecked it too.
Yet both logos show on the front end? We might need to find a different conditional. Can you ask polylang for an example conditional we can use?
I asked some developers friends, they said :
if( get_bloginfo( 'language' ) == 'fr-FR' )
OR
if ( strpos( get_bloginfo( 'language' ), 'fr' ) !== FALSE )
So if i undertand well, the code will be :
<?php if ( get_bloginfo( 'language' ) == 'en-US' ) { ?>
<img src="URL TO en_GB logo" />
<?php } elseif ( get_bloginfo( 'language' ) == 'fr-FR' ) { ?>
<img src="URL TO fr_FR logo" />
<?php } ?>
Right?
Yes, if those are indeed the values WP sets, then that should work.
It kinda work. Like it doesn't replace the logo, but add the logo just on its left.
So with CSS i deactivated the logo and placed the new one.
That should do BUT the problem is that this doesn't replace the mobile logo too :/
I'm not sure that this is the right way to do it, i may be wrong.
What do you think?
Any chance you can link me to the site?
Hey Tom, i found out!
I didn't use any hooks or some but some snippet on functions.php (i got help from a programmer).
This is resolved (event if the hook didn't work).
Thanks for your time & help Tom :)
Glad you got it working! :)
Hi, I'm looking for that too
I'm also using Polylang and want a different logo for the second language (the language that is not the site default)
What code should I use?
Perhaps Alexandre can chime in and let us know which solution he went with :)