If you have troubles since the update to WordPress 4.5 please read this post before opening a new thread.
April 22, 2013 at 8:24 am #22312
I finally switched my site back to how it was before Xmas, with WPML running on a wing and a prayer without the config files from Shoutbox. It works, I can change the backend settings and the featured images retain the mouseover activity, which is what I need. So I’m leaving it like that.
However doing it this way means that there are some settings controlled by the theme which cant be set in two languages. So I need to find a way to hardcode them into the theme itself. The most important at the moment is the site logo, because it is a .png file image with text in different languages.
I need to add some code inside one of the .php files (maybe the header?) to check which language the site is showing (from the WPML switcher) and then display the appropriate logo.
Checking with firebug, the logo image seems to be set inside the header container.
richApril 22, 2013 at 4:53 pm #115376
Add following code to functions.php (insert it at the very bottom):
function avia_logo($use_image = "", $sub = "", $headline_type = "h3")
$headline_type = apply_filters('avia_logo_headline_filter', $headline_type);
if(ICL_LANGUAGE_CODE == 'en')
$logo = avia_get_option('logo');
else if(ICL_LANGUAGE_CODE == 'de')
$logo = 'http://mywebsite.com/mysecondlogo.jpg';
$logo = "<img src=".$logo." alt='' />";
$logo = "<$headline_type class='logo'><a href='".home_url('/')."'>".$logo."$sub</a></$headline_type>";
Instead of ‘en’ insert the language shortcut of your primary language and replace ‘de’ with the shortcut of your second language. Then replace http://mywebsite.com/mysecondlogo.jpg with a valid url to an image/logo.April 22, 2013 at 4:58 pm #115377
Thanks for that code.
One thing I didn’t understand… where does the first logo come from? From the url inserted into the Theme Options settings?
richApril 22, 2013 at 7:08 pm #115378
I get an error Dude:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /xxx/html/wp-content/themes/shoutbox/functions.php on line 216
richApril 22, 2013 at 7:17 pm #115379
Sorry! I missed a back tick in the logo url – damn those things are hard to spot!
Now it’s fine!
Thanks Dude!April 23, 2013 at 6:59 am #115380
The topic ‘Hardcoding site logo – WPML workaround’ is closed to new replies.