In various scenarios it is very much required to show/hide few things in different language using CSS/Javascript. The most handy way I found is to add language code to the body class. But how do we do that?
I am using WPML for different languages, so they provide a Simple PHP Code ICL_LANGUAGE_CODE . Add the following to your functions.php
1 2 3 4 |
function addLanguageClassToBody($classes){ return array_merge( $classes, array( ICL_LANGUAGE_CODE ) ); } add_filter('body_class', 'addLanguageClassToBody'); |