Hi,
I have in the header.php a basic image with class "displayed"
<title><?php wp_title(''); ?></title>
<?php wp_head(); ?>
<?php if(WP_VERSION < 3.0): ?>
<link rel="alternate" type="application/rss+xml" title="<?php printf(__('%s RSS Feed', THEME_NS), get_bloginfo('name')); ?>" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="alternate" type="application/atom+xml" title="<?php printf(__('%s Atom Feed', THEME_NS), get_bloginfo('name')); ?>" href="<?php bloginfo('atom_url'); ?>" />
<?php endif; ?>
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<?php if (is_file(TEMPLATEPATH .'/favicon.ico')):?>
<link rel="shortcut icon" href="<?php bloginfo('template_directory'); ?>/favicon.ico" />
<?php endif; ?>
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/script.js"></script>
</head>
<IMG class="displayed" src="http://www.site.com/images/header-bg.jpg" width="990" height="245" /></div>
<body <?php if(function_exists('body_class')) body_class(); ?>>
I would like that when I am on translated pages (with WPML pulgin) the page shows a different image.
Example:
homepage : image
homepage translated: image 2
page1: image
page 1 translated: image 2
post1: image
post1 translated: image 2
category1: image
category1 translated: image 2
Any idea?
Romel Apuya answers:
use the constant
ICL_LANGUAGE_CODE
where en = english, fr = french
if(ICL_LANGUAGE_CODE=='en'){
echo '<img class="displayed" src="http://www.site.com/images/header-bg.jpg" width="990" height="245" />';
}else{
echo '<img class="displayed" src="http://www.site.com/images/header-bg2.jpg" width="990" height="245" />';
}
[[LINK href="http://wpml.org/documentation/support/wpml-coding-api/"]]http://wpml.org/documentation/support/wpml-coding-api/[[/LINK]]
also add your image below the body tag... its not html valid to add it above the body tag
noronha comments:
So, is this the exact code I have to insert in the header.php file, after </head> and before <body>?
<?php if(ICL_LANGUAGE_CODE=='en'){
echo '<img class="displayed" src="http://www.site.com/images/header-bg.jpg" width="990" height="245" />';
}else{
echo '<img class="displayed" src="http://www.site.com/images/images/header-bgeng.jpg" width="990" height="245" />';
}
Romel Apuya comments:
yes.. but should be after the body tag.
Romel Apuya comments:
<?php if(ICL_LANGUAGE_CODE=='en'){
echo '<img class="displayed" src="http://www.site.com/images/header-bg.jpg" width="990" height="245" />';
}else{
echo '<img class="displayed" src="http://www.site.com/images/images/header-bgeng.jpg" width="990" height="245" />';
}
?>
Romel Apuya comments:
<title><?php wp_title(''); ?></title>
<?php wp_head(); ?>
<?php if(WP_VERSION < 3.0): ?>
<link rel="alternate" type="application/rss+xml" title="<?php printf(__('%s RSS Feed', THEME_NS), get_bloginfo('name')); ?>" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="alternate" type="application/atom+xml" title="<?php printf(__('%s Atom Feed', THEME_NS), get_bloginfo('name')); ?>" href="<?php bloginfo('atom_url'); ?>" />
<?php endif; ?>
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<?php if (is_file(TEMPLATEPATH .'/favicon.ico')):?>
<link rel="shortcut icon" href="<?php bloginfo('template_directory'); ?>/favicon.ico" />
<?php endif; ?>
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/script.js"></script>
</head>
<body <?php if(function_exists('body_class')) body_class(); ?>>
<?php if(ICL_LANGUAGE_CODE=='en'){
echo '<img class="displayed" src="http://www.site.com/images/header-bg.jpg" width="990" height="245" />';
}else{
echo '<img class="displayed" src="http://www.site.com/images/images/header-bgeng.jpg" width="990" height="245" />';
}
?>
noronha comments:
thank you!! it works!!