Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
If else language wordpress (polylang)
<?php
$currentlang = get_bloginfo('language');
if($currentlang=="en-GB"):
?>
<?php elseif($currentlang=="pl-PL"): ?>
<?php endif; ?>
@CultureInspired

This comment has been minimized.

Copy link

@CultureInspired CultureInspired commented Oct 2, 2017

you beautiful bastard <3

@ebkjiud

This comment has been minimized.

Copy link

@ebkjiud ebkjiud commented Oct 25, 2017

$currentlang=="en-GB" or $currentlang == "en-GB"

@MikeiLL

This comment has been minimized.

Copy link

@MikeiLL MikeiLL commented Apr 25, 2018

Nice! For me when I print_r the $currentlang it was All Caps, so just to be sure:

$currentlang = strtoupper(get_bloginfo('language'));
@giorgioriccardi

This comment has been minimized.

Copy link

@giorgioriccardi giorgioriccardi commented May 15, 2018

starting from your snippet I solved my issue and following this other snippet from https://css-tricks.com/forums/topic/php-html-lang-attribute-if-statement/ I ended up also solving the problem for different versions of "en-GB"," en-US", "en-CA" etc, like this:

<?php if(ICL_LANGUAGE_CODE=='en'): ?>
// do stuff
<?php elseif(ICL_LANGUAGE_CODE=='fr'): ?>
// do other stuff
<?php endif; ?>

@Altug

This comment has been minimized.

Copy link

@Altug Altug commented Oct 18, 2019

<3 Thanks a lot!

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