## php – WORDPRESS – GTranslate Plugin – Showing Different Codes With if-else

Question

I’m trying to show different codes for different languages on the gtranslate WordPress plugin.

Here is what I’m trying to do:

<figure>
<?php
$current_lang_code =$_SERVER['HTTP_X_GT_LANG'];
if ($current_lang_code === 'ru') { ?> <img class="img-fit" src="https://www.mgc.com.tr/wp-content/uploads/2022/10/mgc-slider-rusca-v1-sks.jpg" alt="İstanbul Hukuk Bürosu"> <?php } else if ($current_lang_code === 'ar') { ?>
<img class="img-fit" src="https://www.mgc.com.tr/wp-content/uploads/2022/10/mgc-slider-arapca-v1-sks.jpg" alt="İstanbul Hukuk Bürosu">
<?php } else { echo do_shortcode('[metaslider id="6449"]'); } ?>
</figure>


So the idea is that I’m going to show my slider on my Turkish original website and show the other two images on the translated versions, which are automatically translated by gtranslate plugin. It seems to work but sometimes it gets cached or shows the wrong image (for example, Russian image when you are on the Arabic page, etc.). How can I make this work properly?

I don’t have any active cache plugin right now, but I will activate in the future of course.

Thank you, regards.

0
1 month 2022-10-16T11:29:48-05:00 0 Answers 0 views 0