Something like this should work (untested)
<?php if('de' == pll_current_language()) { ?>
<h1>Deutsch</h1>
<?php } elseif ('en' == pll_current_language()) { ?>
<h1>English</h1>
<?php } else { ?>
<h1>Martian</h1>
<?php } ?>
Or, if you are already in a php block, you could rewrite the above into:
if('de' == pll_current_language()) {
echo "<h1>Deutsch</h1>";
} elseif ('en' == pll_current_language()) {
echo "<h1>English</h1>";
} else {
echo "<h1>Martian</h1>";
}
I have added, as you can see, three possibilities: German, English, something else. Your exact question would be translated as:
if('de' == pll_current_language()) {
echo "<h1>Deutsch</h1>";
} else {
echo "<h1>Anything else</h1>";
}
But you get the idea.
Hey Ditto Dito!
Thank you very much! 1,000,000 Kisses (no, I am not gay, in case you are a dude). You made my day! Thank You. Thank you. Thank you.
Awesome indeed.
But what *I* 🙂 need to do is use your bit of code to change the logo depending on the language.
In the header.php, here’s what I have for displaying the logo:
<div id=”header-logo-image”>
” title=”<?php echo esc_attr( get_bloginfo( ‘name’, ‘display’ ) ); ?>” rel=”home”><img src=”<?php echo of_get_option( ‘spacious_header_logo_image’, ” ); ?>” alt=”<?php echo esc_attr( get_bloginfo( ‘name’, ‘display’ ) ); ?>”>
</div>
I would think the important bit is this one:
<img src=”<?php echo of_get_option( ‘spacious_header_logo_image’, ” ); ?>” alt=”<?php echo esc_attr( get_bloginfo( ‘name’, ‘display’ ) ); ?>”>
Could I do something like this?
<img src=”<?php echo
if(‘fr’ == pll_current_language()) {
echo “wp-content/uploads/2014/11/Logo.png”;}
else {
echo “wp-content/uploads/2015/02/Logo-en.png”;}
; ?>” alt=”<?php echo esc_attr( get_bloginfo( ‘name’, ‘display’ ) ); ?>”>
Thank you for your feedback 🙂
I think basically your idea should work but I am not sure whether your PHP syntax is correct (I am a newbie in PHP). I think there is at least one ‘echo’ too much (first line)?