-
AuthorPosts
-
August 1, 2024 at 3:46 pm #1463532
Hi, I’m using “Enfold“ theme with the “Polylang” multilingual plugin. I’m trying to have another version of the main logo on my second language but I cant’ figure it out.
Somebody knows how to have two different logo for each language version?Thanks for your help,
Arthur
August 2, 2024 at 5:36 am #1463571Hey denisbarnabe,
Thank you for the inquiry.
Please use this filter in the functions.php file to change the logo for a specific language:
function avf_logo_mod($logo) { $lang = pll_current_language('locale'); if ($lang == "fr_FR") { $logo = "/wp-content/uploads/YOUR_LOGO_FILE.jpg"; } return $logo; } add_filter('avf_logo', 'avf_logo_mod');
Best regards,
IsmaelAugust 2, 2024 at 8:38 am #1463598oh – nice; I didn’t realise that polylang has an extra for currentLanguage
with get_bloginfo() you can have info on current language too.
function change_logo_on_different_languages($logo){ $currentlang = get_bloginfo('language'); if($currentlang == "fr_FR"){ $logo = "/wp-content/uploads/YOUR_LOGO_FILE.jpg"; } return $logo; } add_filter('avf_logo','change_logo_on_different_languages');
August 2, 2024 at 9:52 am #1463606Thanks for your responses Ismael and Guenni :)
I tried to add this function to my theme but even after purged caches nothing changed on my FR version :/
Do you think could be for the reason I’m using the two features “Logo” and “Logo Transparency” (when the user scroll another logo appears) ? Or maybe for the reason I’m using SVG file ?Thanks for your help :)
Arthur
August 2, 2024 at 2:06 pm #1463652Yes – and if you use for both logo svg files you can replace it by the ID of that logo file.
you can find that ID on media library list view! ( it is an own column for that )try for default logo:
function change_logo_on_different_languages($logo){ $currentlang = get_bloginfo('language'); if($currentlang == "fr_FR"){ // see on media library what ID your Logo for Fr site has. $logo = 162; } return $logo; } add_filter('avf_logo','change_logo_on_different_languages');
and for transparency logo:
function av_change_alternative_logo_img($header){ $currentlang = get_bloginfo('language'); if($currentlang == "fr_FR"){ // next line is only neccessary if on options no default transparency logo has been set $header['header_class'] .= ' av_alternate_logo_active'; $header['header_replacement_logo_id'] = 163; } return $header; } add_filter('avf_header_setting_filter','av_change_alternative_logo_img');
or adjust Ismaels code that way with ID’s
August 2, 2024 at 6:08 pm #1463670That works perfectly, thank you very much for your help Guenni! :D
August 3, 2024 at 5:34 pm #1463707Hi,
Glad that Guenni007 could help, thanks Guenni007, if you have any further questions please open a new thread and we will be happy to help.Best regards,
Mike -
AuthorPosts
- The topic ‘Translate Main Logo’ is closed to new replies.