I like More Lang plugin because there are no duplicate pages and posts for other language versions in the admin panel. But I had a problem – for the banners on the home page (which are embedded in the theme) there was no way to change the texts dynamically, depending on the selected language.
Data for testing: each language on the site has its own prefix in the URL (RU, RF and default EN – the prefix is disabled, because the site works with the English version by default).
Here is the code that I add to functions.php in the current theme and the shortcode to use:
function webinp_banner1_shortcode() { if(strpos($_SERVER['REQUEST_URI'], 'ru/') !== false){ return '<div class="alt-font">text for Russian version</div>'; } else if(strpos($_SERVER['REQUEST_URI'], 'fr/') !== false){ return '<div class="alt-font">text for French version</div>'; } else return '<div class="alt-font">text for English version</div>'; } add_shortcode('banner1shortcode', 'webinp_banner1_shortcode');
Here is the shortcode:
[banner1shortcode]