Title: Conditionally display code based on active language in template
Last modified: April 4, 2018

---

# Conditionally display code based on active language in template

 *  Resolved [bluedrag](https://wordpress.org/support/users/bluedrag/)
 * (@bluedrag)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/conditionally-display-code-based-on-active-language-in-template/)
 * I have a slideshow I am display on my side with PHP code in the template. I’d
   like to swap out the slideshow based on which language is active. Is there any
   way to do this with polylang? For example:
 *     ```
       if (lang == 'en') {
         echo english-slideshow;
       } else if (lang == 'fr') {
         echo french-slideshow;
       }
       ```
   

Viewing 1 replies (of 1 total)

 *  Thread Starter [bluedrag](https://wordpress.org/support/users/bluedrag/)
 * (@bluedrag)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/conditionally-display-code-based-on-active-language-in-template/#post-10147075)
 * I was able to solve this issue with the following code:
 *     ```
          	<?php 
                       if(pll_current_language() == 'en') {
                           echo 'Only in english';
                       } else if(pll_current_language() == 'fr') {
                           echo echo 'Seulment en francais'; 
                       }  
               ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Conditionally display code based on active language in template’ is closed
to new replies.

 * ![](https://ps.w.org/polylang/assets/icon-256x256.png?rev=3433336)
 * [Polylang](https://wordpress.org/plugins/polylang/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/polylang/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/polylang/)
 * [Active Topics](https://wordpress.org/support/plugin/polylang/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/polylang/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/polylang/reviews/)

## Tags

 * [active](https://wordpress.org/support/topic-tag/active/)
 * [else](https://wordpress.org/support/topic-tag/else/)
 * [if statement](https://wordpress.org/support/topic-tag/if-statement/)
 * [language](https://wordpress.org/support/topic-tag/language/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [template](https://wordpress.org/support/topic-tag/template/)

 * 1 reply
 * 1 participant
 * Last reply from: [bluedrag](https://wordpress.org/support/users/bluedrag/)
 * Last activity: [8 years, 1 month ago](https://wordpress.org/support/topic/conditionally-display-code-based-on-active-language-in-template/#post-10147075)
 * Status: resolved