Title: Append query string
Last modified: August 12, 2021

---

# Append query string

 *  Resolved [Daniel Letschka](https://wordpress.org/support/users/dinonid/)
 * (@dinonid)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/append-query-string-2/)
 * Hi,
 * is there a way to apend url parameters like ?lang=en to the english version of
   a website?
 * We need to redirect some pages to another website and somehow need to send information
   which language the user is coming from.
 * Thanks for your help!
    Daniel
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fappend-query-string-2%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [Chouby](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/append-query-string-2/#post-14761937)
 * Hello,
 * By default the language code is stored as `/en/` in the url. The only situation
   where Polylang uses a query string `?lang=en` is when WordPress is set to use
   plain permalinks but that would mean using ugly permalinks everywhere.
 * If you don’t mind digging in PHP, here is the function that we use to get the
   language code from the url when using pretty permalinks as you do: [https://github.com/polylang/polylang/blob/3.1/include/links-directory.php#L121-L133](https://github.com/polylang/polylang/blob/3.1/include/links-directory.php#L121-L133)
 *  Thread Starter [Daniel Letschka](https://wordpress.org/support/users/dinonid/)
 * (@dinonid)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/append-query-string-2/#post-14763994)
 * Hello!
 * Thank you!
 * I don’t mind digging in PHP a bit, however I’m not sure how we could use this
   function to communicate the set language to another website.
 * So when someone clicks lets say on “[https://biocache.biodiversityatlas.at/explore/your-area&#8221](https://biocache.biodiversityatlas.at/explore/your-area&#8221);(
   this is a link on the homepage) – this page needs to know which language the 
   user is coming from.
 * Thanks again for your help,
    Best regards, Daniel
 *  Plugin Author [Chouby](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/append-query-string-2/#post-14764637)
 * It depends if you have access to the code of the other site which could read 
   the language in the url.
 * Another way could be to change the Polylang links model through this filter: 
   [https://github.com/polylang/polylang/blob/3.1/include/model.php#L587-L595](https://github.com/polylang/polylang/blob/3.1/include/model.php#L587-L595).
   A links model is a child class of `PLL_Links_Model`.
 * I am not sure that using `PLL_Links_Default` (the model used for plain permalinks)
   directly with pretty permalinks would work (I never tested it). But maybe you
   can create a child class from `PLL_Links_Directory` (the default model used with
   pretty permalinks fro one domain) and override the method `add_language_to_link()`
   to add your query string. That way you let Polylang work as usual and you just
   add your query string to be interpreted by your other site.
 *  Thread Starter [Daniel Letschka](https://wordpress.org/support/users/dinonid/)
 * (@dinonid)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/append-query-string-2/#post-14765065)
 * Thank you!
 * We solved it with javascript now. We check if the url contains “/en/” and depending
   on the result write a value to local storage.
 * The non-wordpress-pages we link to are on a subdomain, so that works.
 * Best,
    Daniel

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

The topic ‘Append query string’ 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/)

 * 4 replies
 * 2 participants
 * Last reply from: [Daniel Letschka](https://wordpress.org/support/users/dinonid/)
 * Last activity: [4 years, 9 months ago](https://wordpress.org/support/topic/append-query-string-2/#post-14765065)
 * Status: resolved