• I noticed when updating my categories, that Polylang automatically started adding the language code to the slug, even though my category-slugs have identical names in the different languages.

    Example:

    • “Italie-nl” (before: “italie”)
    • “Italy-en” (before: “italy”)

    It’s impossible to remove the language code, because even after updating it again without the language code, it adds it back automatically.

    This new problem is creating big problems on my website since existing links to the categories are broken and result in a 404.

    How can this be fixed?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Chouby

    (@chouby)

    Hello,

    By default, WordPress doesn’t allow two categories to share the same slug. In fact if you attempt to create 2 categories with the same name on a fresh WordPress install (without Polylang), WP will fail to create the second category with the error A term with the name provided already exists with this parent.

    For posts or pages, WordPress circumvents this limitation by adding a -2, -3, etc… For categories, I was sure that users would like to add categories with the same name in several languages. So I found a way to circumvent the WordPress limitation but I needed to change the slug from one category to the other. I believe that the language code looks better than the number added by WP for posts.

    At the time I started writing Polylang, sharing term slugs was totally impossible due to a hard limit in the database. But for several years, this hard limit has been removed and although not easy, it’s now possible to have exactly the same slug for 2 categories in different languages. I however added this feature only in Polylang Pro. See https://polylang.pro/doc/can-posts-or-terms-share-the-same-url-slug-across-translations/

    Thread Starter MijnReiservaring

    (@mceblackbird)

    Thanks for your reply.

    I agree it’s a nice addition to add the language code instead of -2 to the same slugs.

    Before, I only had Polylang add this language code to category slugs with the same name, just like you mention. Example:

    • myanmar
    • myanmar-en

    Only, this time it still adds the language code to my existing category slugs after I updated them (for example, after adding a description). I can’t find the duplicated category slug anywhere and never had this problem before. Example:

    • italie-nl
    • italy-en

    As you can see, the country names have a different translations and shouldn’t get a language code added to them. But it’s not possible to remove it either.

    I’m trying to figure out what could be the source of this problem. Would you have an idea where to find the solution and possible duplicate slugs?

    Thanks!

    Thread Starter MijnReiservaring

    (@mceblackbird)

    Hello @chouby ,

    I would like to receive some help with my problem since it definitely seems to be related to Polylang and I can’t find any solution.

    I assigned each of my existing categories to a certain parent category. Example:

    • Asia > Myanmar > [post-name]

    After doing this, Polylang adds a -en or -nl (depending on the language) to the slug of the child category (myanmar-en), ruining my URL structure and resulting in 404’s.

    It’s impossible to remove these language codes from the slugs, even if I set the assigned parent category back to none.

    This shouldn’t result in an automatic slug change and I haven’t seen other people that are not using Polylang with the same problem, so my guess is it’s related to the plugin.

    Could you please assist me in solving this because this has disastrous effects on my SEO.

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

The topic ‘Why does Polylang adds language code to slug?’ is closed to new replies.