In version 2.8.2, I used the following code to convert all the URLs ending in html normally, but after updating to 2.8.7…
.html changed to -html
Original link: https://www.test.com/test.html
Translated link: https://www.test.com/en/test-html
With the following code, my sitemap shows the correct URL and the translated URL on all pages of the site, but when I click on it, it will jump from .html 301 to -html.
add_filter( 'trp_get_url_for_language', 'trpc_remove_end_slash', 10, 6);
function trpc_remove_end_slash($new_url, $url, $language, $abs_home, $lang_from_url_string, $lang_url_slug){
if (strpos($new_url, '.html') !== false || strpos($new_url, 'sitemap.xml') !== false){
return untrailingslashit($new_url);
}
return $new_url;
}
If I don’t use the code above, I’ll see a .html/ ending in my sitemap. After clicking, it will still 301 jump to the end of -html.
I’ve tried turning on the fix option for using older versions in 2.8.7 and downgrading to 2.8.2, but all my translated links are with the above issue. Please help provide me with a useful function, thank you very much!