Skip to content

Instantly share code, notes, and snippets.

@giorgioriccardi
Forked from beovulf/if_else_lang.php
Last active May 15, 2018 20:59
Show Gist options
  • Save giorgioriccardi/213a055d115b2ae3399db978b6eafe4e to your computer and use it in GitHub Desktop.
Save giorgioriccardi/213a055d115b2ae3399db978b6eafe4e to your computer and use it in GitHub Desktop.
If else language wordpress (polylang)
<?php
$currentlang = get_bloginfo('language');
if($currentlang=="en-CA"):
?>
<?php elseif($currentlang=="fr-CA"): ?>
<?php endif; ?>
or to avoid limitations or issues with "en-CA" "en-GB" "en-US" "en-UK" "fr-FR" etc:
<?php if(ICL_LANGUAGE_CODE=='en'): ?>
<h2>I'm an English page</h2>
<?php elseif(ICL_LANGUAGE_CODE=='fr'): ?>
<h2>Je suis une page en Français</h2>
<?php endif; ?>
<!-- https://css-tricks.com/forums/topic/php-html-lang-attribute-if-statement/ -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment