Bug with query string param ?lang=
-
Hello
When I go to my sitemap:
it’s fine.
But if I want to show my sitemap in another language like “fr”, like this:
http://MYWEBSITE/sitemap.xml?lang=fr
The generated links are at this format:
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
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
The topic ‘Bug with query string param ?lang=’ is closed to new replies.