Checking current language in a function
-
16-10-2019 - |
Question
I am running WordPress with "WPML Multilingual CMS", so that it has multiple language versions.
In a function used with add_action('template_redirect',<functionname>)
, I need to find out what the current language is.
What should I call?
Solution
I have no experience with the plugin whatsoever, but from a quick scout of their site, it looks like:
ICL_LANGUAGE_CODE
will give you the current language. Worth a try, anyway!
OTHER TIPS
Try this one, it worked very fine with me.
$lang=get_bloginfo("language");
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange