Search code examples
wordpresssearchqtranslate

Wordpress Qtranslate keep don't keep lang on word search


On my wordpress blog I installed Qtranslate plugin and it is working fine for my pages and posts.It adds lang=en at the end of all my pages and posts urls.

The problem is that in my top bar I have a search form :

<form method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<input type="search" results=""class="field" name="s" id="s" placeholder="<?php esc_attr_e( 'Search', 'twentyeleven' ); ?>" />
</form> 

and Qtranslate is not adding its lang parameter here when I search for a word:

http://myblog/?s=word-to-look-for

So that whenever I search for a word and I get the results page the blog language switch back to default (en_US)

How could I solve that?

thanks

Luca


Solution

  • Could you switch your site to the other (and better for SEO), url rewrite where it adds the language code at the end?

    Works for here http://www.specialolympics.ca/fr/?s=test

    The other option would be to add a hidden field to the search form:

    <input type="hidden" name="lang" value="<?php echo qtrans_getLanguage(); ?>">