Skip to content

Instantly share code, notes, and snippets.

@beovulf
Created December 1, 2016 08:19
Show Gist options
  • Save beovulf/5a1c26bec2eadd7bde413fc81df31771 to your computer and use it in GitHub Desktop.
Save beovulf/5a1c26bec2eadd7bde413fc81df31771 to your computer and use it in GitHub Desktop.
If else language wordpress (polylang)
<?php
$currentlang = get_bloginfo('language');
if($currentlang=="en-GB"):
?>
<?php elseif($currentlang=="pl-PL"): ?>
<?php endif; ?>
@borodin-dev
Copy link

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; ?>

thanks 🤝
great solution. this helped me a lot.

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