qTranslate plugin switching language in the same page

markobarna picture markobarna · May 15, 2013 · Viewed 11.2k times · Source

I have a serious problem with a qTranslate buttons.
Right now the web structure is: http://www.site.com/news/?lang=en

When I stay in the home page and I try to change the language, the botton opens the first post (maybe because I'm using permalink):

<?php if(qtrans_getLanguage()=='it'): ?>
    <li><a href="<?php echo qtrans_convertURL(get_permalink(), 'en'); ?>" >eng</a></li>
    <li class="liguaattiva">ita</li>
<?php endif; ?>
<?php if(qtrans_getLanguage()=='en'): ?>
    <li class="liguaattiva">eng</li>
    <li><a href="<?php echo qtrans_convertURL(get_permalink(), 'it'); ?>" >ita</a></li>
<?php endif; ?>

How to solve this without open the last post or come back at the home page, but only switching language in the same page?

Answer

user850010 picture user850010 · May 27, 2013

I'm using qTranslate on my project and I do not do any of that stuff you do in your code above and have no problem switching between languages.

All I do is call qts_language_menu() function that creates language menu, nothing else. This will create necessary links which ables you to switch between languages but stay on the same page.