Title: Bug with query string param ?lang=
Last modified: August 31, 2016

---

# Bug with query string param ?lang=

 *  Resolved [nervus70](https://wordpress.org/support/users/nervus70/)
 * (@nervus70)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/bug-with-query-string-param-lang/)
 * Hello
 * When I go to my sitemap:
 * [http://MYWEBSITE/sitemap.xml](http://MYWEBSITE/sitemap.xml)
 * it’s fine.
 * But if I want to show my sitemap in another language like “fr”, like this:
 * [http://MYWEBSITE/sitemap.xml?lang=fr](http://MYWEBSITE/sitemap.xml?lang=fr)
 * The generated links are at this format:
 * [http://MYWEBSITE?lang=fr/sitemap-home.xml](http://MYWEBSITE?lang=fr/sitemap-home.xml)
 * Witch is wrong.
 * I fixed it by modifying the function “get_index_url()”
 * Old code:
 *     ```
       public function get_index_url( $sitemap = 'home', $type = false, $param = false )
       	{
       		$root =  esc_url( trailingslashit(home_url()) );
       		$name = $this->base_name.'-'.$sitemap;
   
       		if ( $type )
       			$name .= '-'.$type;
   
       		if ( '' == get_option('permalink_structure') || '1' != get_option('blog_public')) {
       			$name = '?feed='.$name;
       			$name .= $param ? '&m='.$param : '';
       		} else {
       			$name .= $param ? '.'.$param : '';
       			$name .= '.'.$this->extension;
       		}
   
       		return $root . $name;
       	}
       ```
   
 * New code:
 *     ```
       public function get_index_url( $sitemap = 'home', $type = false, $param = false )
       	{
       		$split_url = explode('?', home_url());
       		$query_string_lang = (isset($split_url[1]) ? $split_url[1] : '');
       		$home_url = $split_url[0];
   
       		$root =  esc_url( trailingslashit($home_url) );
   
       		$name = $this->base_name.'-'.$sitemap;
   
       		if ( $type )
       			$name .= '-'.$type;
   
       		if ( '' == get_option('permalink_structure') || '1' != get_option('blog_public')) {
       			$name = '?feed='.$name;
       			$name .= $param ? '&m='.$param : '';
       			return $root . $name . '&' . $query_string_lang;
       		} else {
       			$name .= $param ? '.'.$param : '';
       			$name .= '.'.$this->extension;
       			return $root . $name . '?' . $query_string_lang;
       		}
   
       	}
       ```
   
 * Please fix it in the next version 🙂
 * Thank you
 * [https://wordpress.org/plugins/xml-sitemap-feed/](https://wordpress.org/plugins/xml-sitemap-feed/)

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

 *  Plugin Author [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * (@ravanh)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/bug-with-query-string-param-lang/#post-7328697)
 * Which multilanguage plugin are you using?
 *  Thread Starter [nervus70](https://wordpress.org/support/users/nervus70/)
 * (@nervus70)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/bug-with-query-string-param-lang/#post-7328722)
 * WPML
 *  Plugin Author [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * (@ravanh)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/bug-with-query-string-param-lang/#post-7328769)
 * OK, interesting. I’m trying to improve WPML compatibility but since I don’t have
   the plugin and the WPML developers are not telling me everything (I think, or
   I’m not asking the right questions) I’m working in the dark. Your experience 
   and feedback might help me further 🙂
 * Does your site have all French posts only accessible via `?lang=fr` after the
   URL or also via `/fr/` inside the URL?
 *  Thread Starter [nervus70](https://wordpress.org/support/users/nervus70/)
 * (@nervus70)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/bug-with-query-string-param-lang/#post-7328800)
 * Indeed only via ?lang=fr 🙂
 *  Thread Starter [nervus70](https://wordpress.org/support/users/nervus70/)
 * (@nervus70)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/bug-with-query-string-param-lang/#post-7328801)
 * If you prefer asking questions live, I’m available on skype: Nervus70
    Thank 
   you for your help
 *  Plugin Author [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * (@ravanh)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/bug-with-query-string-param-lang/#post-7328873)
 * That’s very kind of you, I might take you up on that later. I should be able 
   to revive my old Skype account 😉
 * In the mean time, I’ve got a development version (4.7 alpha) on [https://github.com/RavanH/xml-sitemap-feed](https://github.com/RavanH/xml-sitemap-feed)
   with a variant of you split code implemented, plus another WPML compatibility
   addition which has not been tested yet. The addition is supposed to cause all
   languages to be present in the sitemaps, instead of only the default. But because
   I don’t have WPML, I cannot verify this.
 * Could you download it (button Download ZIP on the right) extract and overwrite
   current plugin files by FTP?
 * If you have a development version of your site, you might want to test it there.
   It’s an alpha release after all 🙂
 *  Plugin Author [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * (@ravanh)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/bug-with-query-string-param-lang/#post-7328906)
 * Hi @mervus70 – version 4.7+ should be fully compatible with WPML. Please let 
   me know if you find any issues 🙂
 *  Thread Starter [nervus70](https://wordpress.org/support/users/nervus70/)
 * (@nervus70)
 * [10 years ago](https://wordpress.org/support/topic/bug-with-query-string-param-lang/#post-7328923)
 * Hi,
 * Sorry I was on holiday for 2 weeks.
    Thank you a lot for your reactivity, we 
   will update and test the plugin ASAP.
 * I keep you posted

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

The topic ‘Bug with query string param ?lang=’ is closed to new replies.

 * ![](https://ps.w.org/xml-sitemap-feed/assets/icon-128x128.png?rev=1112143)
 * [XML Sitemap & Google News](https://wordpress.org/plugins/xml-sitemap-feed/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/xml-sitemap-feed/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/xml-sitemap-feed/)
 * [Active Topics](https://wordpress.org/support/plugin/xml-sitemap-feed/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/xml-sitemap-feed/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/xml-sitemap-feed/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [nervus70](https://wordpress.org/support/users/nervus70/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/bug-with-query-string-param-lang/#post-7328923)
 * Status: resolved