Jump to content
Sign in to follow this  
augemundial

How to change header site logo according to language

Recommended Posts

augemundial

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 :)

Share this post


Link to post
Share on other sites
cmunns

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
augemundial

Adam, Yeah I can use ICL_LANGUAGE_CODE to know what language is currently being used. I'm new with Wordpress, can you give an example of your idea? Thank you

Share this post


Link to post
Share on other sites
augemundial

Sorry to bounce, but I really need to get this done this week :)

Share this post


Link to post
Share on other sites
kastelic

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( '%s', '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

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') { ?> logo-eng-2012.png <?php???} else if (ICL_LANGUAGE_CODE == 'fr') {????>???logo-fr-2012.png 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') { ?> logo-eng-2012.png <?php } else if (ICL_LANGUAGE_CODE == 'es') { ?> logo-es-2012.png <?php } else if (ICL_LANGUAGE_CODE == 'ca') {?> logo-ca-2012.png <?php } else if (ICL_LANGUAGE_CODE == 'fr') { ?> logo-fr-2012.png <?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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×