-
AuthorPosts
-
October 18, 2022 at 5:58 pm #1369265
Hi there!
Is it possible to change the logo of my main menu depending on the language? In my case, it should switch between Spanish and German.
Thanks in advance
ArantzaOctober 18, 2022 at 6:32 pm #1369269Hey asociacionespanolaaustria,
Yes, you can do that in the theme option under each selected language when running WPML.
Best regards,
RikardOctober 18, 2022 at 7:17 pm #1369279Thank you for your answer. I worked with Polylang
October 18, 2022 at 7:54 pm #1369285It is not possible to change the logo. Can you please help me?
October 18, 2022 at 9:58 pm #1369289Hi! In the theme option, I only have the possibility of loading a Logo. I can not change it for different languages.
What should I doOctober 19, 2022 at 9:05 am #1369353This reply has been marked as private.October 19, 2022 at 9:57 am #1369358i do not know if polylang has some classes on body for each language – but on htm there is that lang attribut you can check.
you then can use a filter to change logo with an if clause checking for lang:function change_logo_by_lang($logo){ $currentlang = get_bloginfo('language'); if($currentlang=="en-GB"){ $logo = "/wp-content/uploads/YOUR_LOGO_FILE.jpg"; } return $logo; } add_filter('avf_logo','change_logo_by_lang');
by that you can even differ on f.e.: en-US, en-CA, en-AU, en-GB, en-UK
October 19, 2022 at 10:15 am #1369364no chance :(
thank you anyway
best regards
ArantzaOctober 19, 2022 at 10:42 am #1369367I for one test almost all my advice beforehand.
So as long as you have a lang attribute to html, it should work.
As I said – I don’t have Polylang running on a test installation, so I don’t know how Polylang switches between languages, but I can’t imagine the lang attribute not being set. WPML does it that way, anyway.The lang attributes can be determined using the developer tools, and the path to the alternative logo must of course be replaced.
If you use transparent headers, which you didn’t mention, you won’t see the actual logo at the beginning.if you try to substitute the transparency logo on some pages use
function replace_transparent_logo_on_some_pages($header){ $currentlang = get_bloginfo('language'); if($currentlang=="de-DE"){ $header['header_replacement_logo'] = "/wp-content/uploads/YOUR_ALTERNATE_LOGO"; } return $header; } add_filter('avf_header_setting_filter','replace_transparent_logo_on_some_pages');
i tested this – but if there is set on “Transparency Options” a svg as logo – this will not replace this. It seems that the replacement of the img svg to an inline svg hampers that filter from changing the output.
October 20, 2022 at 11:22 am #1369562October 20, 2022 at 11:25 am #1369565Guenni007 is a real asset..:)
October 20, 2022 at 11:34 am #1369570i tested this – but if there is set on “Transparency Options” a svg as logo – this will not replace this. It seems that the replacement of the img svg to an inline svg hampers that filter from changing the output.
i do not know if i could avoid it by giving to the function a high priority ( low numbers : 10 )
December 7, 2022 at 11:40 am #1375329Hi,
I am using polylang for de and en pages and everything works fine, BUT:Clicking on the LOGO on any english page I get a wrong link to the english HOME. (The HOME-button in the menu works fine.)
How can I change the LOGO-Link on my english pages leading me to my english HOME page?December 7, 2022 at 6:45 pm #1375410can you try something like this:
function av_change_logo_link_for_language($link){ $currentlang = get_bloginfo('language'); if($currentlang=="en-US"){ $link = get_site_url().'/?lang=en'; // you know your permalink structure better than me } return $link; } add_filter('avf_logo_link','av_change_logo_link_for_language');
December 12, 2022 at 10:52 am #1375919This reply has been marked as private.December 12, 2022 at 4:59 pm #1375971Hi,
Could you please try copying the code from here – https://pastebin.com/9dZhSu7Q.
I tested it on my local installation and it works as expected.
Best regards,
YigitDecember 13, 2022 at 11:37 am #1376037Hi Guenni, Hi Yigit,
Now it works! Thanks for your perfect and fast support.
No idea what went wrong before.Best,
MarkusDecember 13, 2022 at 12:28 pm #1376040 -
AuthorPosts
- The topic ‘Different Logo for different languages’ is closed to new replies.