Title: Language switching button doesn&#039;t work
Last modified: August 22, 2016

---

# Language switching button doesn't work

 *  Resolved [sottise](https://wordpress.org/support/users/sottise/)
 * (@sottise)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/language-switching-button-doesnt-work/)
 * I have already asked for help regarding this problem, but as it seems not resolved
   yet, I’m asking for help again.
 * I am using both: “language menu” in my header + my own picture in the sidebar.
   The language menu works well.
    I was using the qtranslate plugin before, and 
   my own button / picture code was working great as well.
 * When I’ve switched to qtranslate-x plugin, it stopped working.
    I mean, switching
   from Fr (the default language) to En works, but it doesn’t works from EN to FR.
 * When I un-check: “Hide URL language information for default language. ” it works!
   But then I can’t access to my wp-admin!
 * Could someone help me with this? Or maybe I could use another code?
 * Here is the code :
 *     ```
       <?php if(qtranxf_getLanguage()=='fr'): ?>
       <div class="langSWITCHER_EN">
       <a class="languen" href="<?php echo getUrlInTargetLanguage("en"); ?>" >Translate</a>
       </div>
   
       <?php endif; ?>
   
       <?php if(qtranxf_getLanguage()=='en'): ?>
       <div class="langSWITCHER_FR">
   
       <a class="langufr" href="<?php echo getUrlInTargetLanguage("fr"); ?>" >Traduire</a>
       </div>
   
       <?php endif; ?>
       ```
   
 * Notice also that I was previously using the qtrans_ code, with the Compatibility
   Functions enabled, but the problem was the same…
 * See [link](http://www.popandsoda.com) and the sidebar image “Je parle français”/“
   I speak English”

Viewing 12 replies - 1 through 12 (of 12 total)

 *  Plugin Author [Gunu](https://wordpress.org/support/users/grafcom/)
 * (@grafcom)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/language-switching-button-doesnt-work/#post-5936204)
 * Hello again,
 * Side bar – can you not use the widget? – Appearance – widgets – Primary Sidebar–
   qTranslate Language Chooser –
 *  Thread Starter [sottise](https://wordpress.org/support/users/sottise/)
 * (@sottise)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/language-switching-button-doesnt-work/#post-5936206)
 * Hello and thanks again for your help Gunu! 🙂
 * Mmmmh, yes, I could, but I would like to use the picture that you see in the 
   sidebar.
    I tried to change the CSS code in the qTranslate Language Chooser widget
   but it was really tricky…
 *  Plugin Author [Gunu](https://wordpress.org/support/users/grafcom/)
 * (@grafcom)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/language-switching-button-doesnt-work/#post-5936240)
 * [@sottise](https://wordpress.org/support/users/sottise/),
 * No idea, but
 * `<a class="langufr" href="<?php echo getUrlInTargetLanguage("fr"); ?>" >Traduire
   </a>`
 * Try change to this:
 * `<a class="langufr" href="<?php echo getUrlInTargetLanguage(""); ?>" >Traduire
   </a>`
 * or something because /fr is disabled ??? eventually we will get there 🙂
 *  Thread Starter [sottise](https://wordpress.org/support/users/sottise/)
 * (@sottise)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/language-switching-button-doesnt-work/#post-5936272)
 * Clever! But unfortunately does not work either… nice try anyway!
 * Maybe we should replace <?php echo getUrlInTargetLanguage by something else but
   I know nothing about php :/
 * And yes, it was working well with the /fr enabled, but since I had problems with
   the admin connexion…
 *  Plugin Author [Gunu](https://wordpress.org/support/users/grafcom/)
 * (@grafcom)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/language-switching-button-doesnt-work/#post-5936277)
 * [@sottise](https://wordpress.org/support/users/sottise/),
 * we will ask John 🙂
 *  Thread Starter [sottise](https://wordpress.org/support/users/sottise/)
 * (@sottise)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/language-switching-button-doesnt-work/#post-5936278)
 * Thanks a bunch Gunu for your concern and your help!!
    Hoping that John will find
   out a solution 🙂
 *  Plugin Author [Gunu](https://wordpress.org/support/users/grafcom/)
 * (@grafcom)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/language-switching-button-doesnt-work/#post-5936281)
 * this could you also try first:
 * change settings – General –
    Wordpress adress URL: popandsoda.com/blog and Site
   adress URL: popandsoda.com/blog
 * please ensure that your code works under popandsoda.com/blog as main site so 
   we can see if that redirect has influence and if the code is standard ok.
 *  Plugin Author [John Clause](https://wordpress.org/support/users/johnclause/)
 * (@johnclause)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/language-switching-button-doesnt-work/#post-5936313)
 * Where is the code of function `getUrlInTargetLanguage('en')`? I never saw this
   function anywhere. Is it a part of theme? Can you try instead `qtranxf_get_url_for_language('','
   en', true)`? Do you use “QTranslate Slug”? It is currently not compatible with-
   X.
 *  Plugin Author [John Clause](https://wordpress.org/support/users/johnclause/)
 * (@johnclause)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/language-switching-button-doesnt-work/#post-5936317)
 * Other solution, which may work without changing the code, disable cookie via 
   option “Cookie Settings”. Something else may get broken, but knowing that it 
   worked under qTranslate before, it might be ok, unless you start using some other
   sophisticated enough plugins like Woocommerce in the future.
 *  Thread Starter [sottise](https://wordpress.org/support/users/sottise/)
 * (@sottise)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/language-switching-button-doesnt-work/#post-5936411)
 * [@john](https://wordpress.org/support/users/john/) Clause:
 * Oups, yes, sorry, indeed, there is a function :
 *     ```
       // Permalink in current language
       function getUrlInTargetLanguage($targetLang){
           global $qtranslate_slug;
           return $qtranslate_slug->get_current_url($targetLang);
       }
       ```
   
 * which is apparently using Qtranslate Slug yes.
 * No, It’s a code that I’ve found somewhere when I was using mqtranslate.
 *  Thread Starter [sottise](https://wordpress.org/support/users/sottise/)
 * (@sottise)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/language-switching-button-doesnt-work/#post-5936412)
 * yeay, apparently it works fine now with the code you gave me!!
 * This is how it looks now:
 *     ```
       <?php if(qtranxf_getLanguage()=='fr'): ?>
   
       <div class="langSWITCHER_EN">
       <a class="languen" href="<?php echo qtranxf_get_url_for_language('', 'en', true); ?>" >Translate</a>
       </div>
   
       <?php endif; ?>
   
       <?php if(qtranxf_getLanguage()=='en'): ?>
       <div class="langSWITCHER_FR">
   
       <a class="langufr" href="<?php echo qtranxf_get_url_for_language('', 'fr', true); ?>" >Traduire</a>
       </div>
   
       <?php endif; ?>
       ```
   
 * I guess the function code is obsolete now?
    Thanks very much to both of you! 
   Great support 🙂
 * PS: I didn’t touched to the cookies option you mentioned.
 *  Plugin Author [Gunu](https://wordpress.org/support/users/grafcom/)
 * (@grafcom)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/language-switching-button-doesnt-work/#post-5936414)
 * [@sottise](https://wordpress.org/support/users/sottise/),
 * Great ! I mark this post as Resolved.
 * Best

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Language switching button doesn't work’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/qtranslate-x_f9f9f9.svg)
 * [qTranslate X](https://wordpress.org/plugins/qtranslate-x/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/qtranslate-x/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/qtranslate-x/)
 * [Active Topics](https://wordpress.org/support/plugin/qtranslate-x/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/qtranslate-x/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/qtranslate-x/reviews/)

 * 12 replies
 * 3 participants
 * Last reply from: [Gunu](https://wordpress.org/support/users/grafcom/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/language-switching-button-doesnt-work/#post-5936414)
 * Status: resolved