How to change header site logo according to language

Recommended Posts

augemundial
0

augemundial 0

I'm using WPML for my multi-language site. However I need to use a different header logo image for my different translations. Somebody knows a way to accomplish this? I just need to know the file where I need to put a simple "if" statement -unless somebody else has a better idea.
Thank u

augemundial
0

augemundial 0

Share this post

Link to post

Share on other sites

cmunns
16

cmunns 16

You could try to filter the branding function ...but first I would need to know if there are conditionals you could use within the WPML that allow you to test whether you are viewing an English v Spanish v etc site?

Share this post

Link to post

Share on other sites

kastelic
6

kastelic 6

Open library.templates.php. The first function there is pagelines_main_logo(). What you want to do is set up a filter for pagelines_site_logo that will change the value of the variable $site_logo based on the conditions of you rif statement.
As a quick example you can copy, here is an example of filtering that function and making it so the logo links to google instead of the home page:
`
add_filter ( 'pagelines_site_logo', 'myfilter');
function myfilter($site_logo){
$site_logo = sprintf( '', 'http:google.com', get_bloginfo('name'), esc_url(pagelines_option('pagelines_custom_logo')), get_bloginfo('name'));
return $site_logo;
}
`
Of course this is done in base/functions.php (you have to have the base child theme activated).

Share this post

Link to post

Share on other sites

antonella
1

antonella 1

Hello,
I am following the instructions above to change the logo according to language through WPML. However, I'm not too experienced with coding functions, so need a few extra steps.
I would like to use this code instead of uploading the logo through the pagelines interface:
<?php???if (ICL_LANGUAGE_CODE == 'en') { ?>
<?php???} else if (ICL_LANGUAGE_CODE == 'fr') {????>???
I added it to the instructions above, but I am probably missing a semi-colon or have my php statement in the wrong place. This is how I did it, but it's not working. I'm getting an error on the site.
add_filter ( 'pagelines_site_logo', 'multilanguage');
function multilanguage($site_logo){
$site_logo = <?php
if (ICL_LANGUAGE_CODE == 'en') { ?>
<?php
} else if (ICL_LANGUAGE_CODE == 'es') { ?>
<?php
} else if (ICL_LANGUAGE_CODE == 'ca') {?>
<?php
} else if (ICL_LANGUAGE_CODE == 'fr') {
?>
<?php
}
?>
;
return $site_logo;
}
The error is occurring on the third line in ($site_logo = <?php ).
Can anyone give me any clues to get to the next step?
Thanks!