I'm using the Polylang wordpress plugin to transform my website into multiple languages.
In the free version it is not allowed to translate the category_base or Tags slug in permalinks.
So I tried to find a solution and I got involved in the plugin https://github.com/KLicheR/wp-polylang-translate-rewrite-slugs
that should do this, I installed the plugin and entered the following snippet in function.php:
add_filter( 'pll_translated_taxonomy_rewrite_slugs', function( $taxonomy_translated_slugs )
{
$taxonomy_translated_slugs = array(
// tax_name
'category' => array(
'it' => 'categoria',
'en' => 'category',
)
);
return $taxonomy_translated_slugs;
});
the snippet I used was found in the plugin README: https://github.com/KLicheR/wp-polylang-translate-rewrite-slugs/blob/master/polylang-translate-rewrite-slugs.php
I updated the Permalinks and it seems that now when I change the language the slug in the url changes.
I noticed though that in the HTML code the HREFLANG tags have a problem, not showing the correct URL.
the correct URLs are:
IT: Mydomain.com/categoria/xxxxxxx
EN: Mydomain.com/en/category/yyyyyy
going to see the HREFLANG tags in the html code I find myself instead:
<link rel = "alternate" href = "Mydomain.com/xxxxxxx" hreflang = "it" />
<link rel = "alternate" href = "Mydomain.com/en/yyyyyy" hreflang = "en" />
So the slugs "category" and "category" are eliminated.
The links in the language switcher widget also have the same problem.
Why not also update these elements?