I am working on a website for a friend of mine, which is multilingual. Therefore I use the plugin Polylang. 'The theme I use is called 'spacious'.
I currently face the problem, that I cant add different logos for different languages, aswell as different header texts/background images.
I googled a bit, and found a possible solution, but I didnt get it to work.
function pojo_polylang_get_multilang_logo( $value ) {
if ( function_exists( 'pll_current_language' ) ) {
$logos = array(
'en' => 'logo_en.jpg',
'fr' => 'logo_fr.jpg',
'de' => 'logo_de.jpg',
'es' => 'logo_esp.jpg',
);
$default_logo = $logos['en'];
$current_lang = pll_current_language();
$assets_url = get_stylesheet_directory_uri() . '/images/';
if ( isset( $logos[ $current_lang ] ) )
$value = $assets_url . $logos[ $current_lang ];
else
$value = $assets_url . $default_logo;
}
return $value;
}
add_filter( 'theme_mod_image_logo', 'pojo_polylang_get_multilang_logo' );
In my understanding, this function first stores the preset Logo filenames in an array, then checks for the current language and depending on the current language, the add_filter() function sets the current logo.
I tried copying this into the functions.php file but it didnt work. My thought is, that it doesnt work, because of the first parameter 'theme_mod_image_logo'. I also googled this php function to get a better understanding of it and to know what parameter to pass to the function. Can someone explain to me who is firm with php, what parameter I need to pass or if you have a better solution for me?
In case this works for the logo, I could also apply this function to a header-image right? Just change the filenames in the array and pass the right parameter?
Thanks already, I would really appreciate your help!! I need to leave now for about one hour or two, and wont be able to respond back during that time!
Edit: I also had a lokk at 'duplicate' question. It didnt help me since, my understanding is not good enough