Hi guys,
I’d like to use the Header Ad section to display a 728×90 image. For now I’ve used the theme options panel to display the first of the images.
Works fine in the first language, English, but as the site has two other language settings, I need this image to change dependent on language, i.e. to be replaced by the image in language two or language three when the switch is made by the user.
Is there a way of achieving this in the template header-style-2.php?
Thanks
Hi Marius
I’m using WPML. Have tried the following in my functions
function hash_header_image_switcher() {
switch(ICL_LANGUAGE_CODE){
case 'en':
$link_to_image = 'top-header-en.png';
break;
case 'fi':
$link_to_image = 'top-header-fi.png';
break;
case 'sv':
$link_to_image = 'top-header-sv.png';
break;
return $link_to_image;
}
}
and then added this in to header-style-2:
<?php echo "<img src=" . hash_header_image_switcher() . " />";?>
but it’s not working.
Any ideas?
Hi Marius,
Have tried all combinations mate. The simplest was to put images in child theme folder and reference files from there.
Currently I have the path as ‘images/top-header-fi.png’; and still no joy. Is there any way of overriding the template that’s being loaded? Not sure what’s up as it should be pretty simple.
Cheers
Hash
Hi Marius,
Here’s a link to the demo version of the site: demo.demofinland.org
The Header file is working fine, just not loading the images.
Currently my images folder is in the same directory as my WP install… http://demo.demofinland.org/images/…still can’t get to it. Not sure what I’m doing wrong. Have tried absolute and relative paths.
Hope we can get a resolve soon…
Cheers
Hi,
That’s exactly what I tried first…I now have:
function header_image_switcher() {
switch(ICL_LANGUAGE_CODE){
case 'en':
$link_to_image = 'http://demo.demofinland.org/images/top-header-en.png';
break;
case 'fi':
$link_to_image = 'http://demo.demofinland.org/images/top-header-fi.png';
break;
case 'sv':
$link_to_image = 'http://demo.demofinland.org/images/top-header-sv.png';
break;
return $link_to_image;
}
}
The Header style 1 template has:
<div class="span8 td-header-style-1">
<?php
// show the header ad spot
/* echo td_global_blocks::get_instance('td_ad_box')->render(array('spot_id' => 'header')); */
echo "<img src=" . header_image_switcher() . " />";
?>
</div>
</div>
And all I get in the inspector is:
<div class="span8 td-header-style-1">
<img src="/"></img>
</div>
I know the code is fine and the language plugin is working great…could it be something else?
Cheers
Hi,
You need to check if that ICL_LANGUAGE_CODE return something. Are you sure this is corent: switch(ICL_LANGUAGE_CODE) if this return nothing there will be no case for language and the function return nothing.
Also you can try to add this on the switch and see if the function to return any language to get the default value. ANd if this work probably that ICL_LANGUAGE_COD doesn’t return the language.
default:
$link_to_image = 'http://demo.demofinland.org/images/top-header-en.png';
break;
Hope this help!
Thanks!