Title: Keep query string when change the language
Last modified: August 24, 2016

---

# Keep query string when change the language

 *  Resolved [JuanMGonzalezR](https://wordpress.org/support/users/juanmgonzalezr/)
 * (@juanmgonzalezr)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/keep-query-string-when-change-the-language/)
 * Hi, in my site i have custom query vars for some pages, like this:
 * > localhost/pagename/5
 *  where “5” is the value of the var
 * when im in that link and i change the language the switcher redirect me to:
 * > localhost/paginanombre
 * i want keep the value of the var like this
 * > localhost/paginanombre/5
 * How can i do this?
 * [https://wordpress.org/plugins/polylang/](https://wordpress.org/plugins/polylang/)

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

 *  Plugin Author [Chouby](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/keep-query-string-when-change-the-language/#post-5993463)
 * Hi!
 * You will have to write your own translation link using the filter [pll_translation_url](https://polylang.wordpress.com/documentation/documentation-for-developers/filter-reference/#pll_translation_url).
 *  Thread Starter [JuanMGonzalezR](https://wordpress.org/support/users/juanmgonzalezr/)
 * (@juanmgonzalezr)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/keep-query-string-when-change-the-language/#post-5993499)
 * Can you give an example?
 *  Thread Starter [JuanMGonzalezR](https://wordpress.org/support/users/juanmgonzalezr/)
 * (@juanmgonzalezr)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/keep-query-string-when-change-the-language/#post-5993570)
 * Well Fixed! thank Chouby
 * Here is my solution, i use[ pll_the_language_link ](https://polylang.wordpress.com/documentation/documentation-for-developers/filter-reference/#pll_the_language_link)
 * and i cut the last two characters of the current link page, append to the url
   translate, and check if the current page is a page with the parameter
 * here is the code:
 *     ```
       add_filter('pll_the_language_link', 'my_link', 10, 2);
       function my_link($url, $slug) {
   
       	$arr=array('pagename',
       		'nombrepagina',
       		'nomepágina',
       			);
   
       	foreach($arr as $a) {
               if (stripos($_SERVER['REQUEST_URI'],$a) !== false) {
               	return $url .substr($_SERVER['REQUEST_URI'], -2);
               	break;
               }
               else
               	return $url;
           }
   
       }
       ```
   

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

The topic ‘Keep query string when change the language’ 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

 * [change](https://wordpress.org/support/topic-tag/change/)
 * [language](https://wordpress.org/support/topic-tag/language/)
 * [Query String](https://wordpress.org/support/topic-tag/query-string/)

 * 3 replies
 * 2 participants
 * Last reply from: [JuanMGonzalezR](https://wordpress.org/support/users/juanmgonzalezr/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/keep-query-string-when-change-the-language/#post-5993570)
 * Status: resolved