Skip to content

Instantly share code, notes, and snippets.

@ChrisCree
Last active September 13, 2015 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisCree/9bf66e32af9ffdca84c3 to your computer and use it in GitHub Desktop.
Save ChrisCree/9bf66e32af9ffdca84c3 to your computer and use it in GitHub Desktop.
Change out logo images in the Genesis theme framework depending on which language is selected via WPML.
<?php
// Don't copy above opening PHP tag
// Display Custom logo based on WPML language displayed
add_action('wp_head','wsm_lang_logo_image_logic');
function wsm_lang_logo_image_logic() {
if ( !defined( 'ICL_LANGUAGE_CODE' ) ) {
return;
}
$language = ICL_LANGUAGE_CODE;
echo '<style type="text/css">';
echo '.header-image .site-title a { background: url("' . get_stylesheet_directory_uri() . '/images/logo-' . $language .'.png") no-repeat 0 center; }';
echo '</style>';
}

Instructions

  • First create your logo images for each language in use name each file adding the two letter language identifier such as logo-fr.png, logo-en.png, etc.
  • Upload each of your language unique logos to your Genesis child theme's /images/ directory on your server
  • Add the above code to your child theme's functions.php file

Then the code will output the CSS needed to swap out the logo image based on the language into your site's markup before the closing tag.

Obviously you may need to adjust your CSS selector to match how your child theme displays its logo image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment