user4195146
user4195146

Reputation:

Get language code of WPML

I'm trying to get the language code of the WPLM wordpress plugin. This is how I'm doing it without luck:

<?php if (ICL_LANGUAGE_CODE == 'es_En') { ?>
    <p>Spanish text</p>
<?php> ?>

Any idea where is the problem? I have check some tutorials and they do this way.

Upvotes: 1

Views: 3404

Answers (2)

rnevius
rnevius

Reputation: 27112

es_En isn't a valid language code. You'll want to just use es:

<?php if (ICL_LANGUAGE_CODE == 'es'): ?>
    <p>Spanish text</p>
<?php endif; ?>

Upvotes: 2

hellcode
hellcode

Reputation: 2698

<?php if (substr(ICL_LANGUAGE_CODE,0,2) == 'es') { ?>
    <p>Spanish text</p>
<?php> ?>

Upvotes: 1

Related Questions