When using the query-mode (the language is noted as an attached ‘?lang=en’ in the URL) a performed search shows the results in the default language (which could be the one selected in the browser settings, not the one chosen by a user).
The Solution:
Add the following to ‘Searchform.php’ in ‘design’ -> ‘Editor’
just in front of the ‘<\form>‘ tag:
<input type="hidden" name="lang" value="<?php echo qtrans_getLanguage(); ?>">
… this way the language-parameter will be added to the URL as a hidden field.
Source: http://stackoverflow.com/questions/8435113/wordpress-qtranslate-keep-dont-keep-lang-on-word-search
My search form code is like this:
…….
echo ”;
echo ‘<input type="hidden" name="lang" value="”>’;
echo ”;
echo ”;
The result is like this: http://itransl.com/?s=9eab94f60d&formid=3321&skeyword=The+Fifth+Estate+&wqsfsubmit=Search&lang=+%3C%3Fphp+echo+qtrans_getLanguage%28%29%3B+%3F%3E+
lang=+%3C%3Fphp+echo+qtrans_getLanguage%28%29%3B+%3F%3E+
value=” doesn’t work. Why??
Because you forgot to add the important part:
value=”< ?php echo qtrans_getLanguage(); ?>
and echo is just printing the text between … just stick to my code lines and it should work 🙂
Such an impiessrve answer! You’ve beaten us all with that!
I have similar problem, with my search link for my template.
<button class="search" type="submit" id="searchsubmit" input type="hidden" name="lang" value="”>{$label}
Or, this does not work like that?
Hey,
it should work if you insert
< ?php echo qtrans_getLanguage(); ?>
as the value (like value = “< ?php echo qtrans_getLanguage(); ?>“). That line will output the currently selected language.