• Resolved ZioChicco

    (@ziochicco)


    Hello!

    I’ve created a custom post type as ‘products’ and now I would like to create a translated version for any of these posts, using polylang’s plugin. The problem is when I try to open the translated version, this won’t be shown. So, for example, the main custom post works fine and I can visit https://www.site.com/post-title/ as normal, but if I try to open https://www.site.com/en/post-title/ it gives 404 error. I have no problem with pages, so the issue seems to be only on CPT.

    After researching, I found out that the actual translated link needs the custom post type slug in order to work, something link https://www.site.com/en/products/post-title/, but I don’t really like this URL to be honest. Is there any chance to use the URL without the slug?

    I also noticed a strange behaviour: if I add ‘en’ as Custom Rewrite Slug in products setting, the translated version of that post type actually work but not the pages anymore! I was wondering why a single CPT setting can affect to the whole website and brokes the page’s URL.

    Thank you for your help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I suspect the requirement to have “products” in the URL is going to have to be the case, otherwise WordPress doesn’t know what you’re intending it to query for. In this case, the presence of “products” is saying “this is the post type, and we want the post named ‘post-title’ from that post type”. It’s definitely things coming from WordPress core itself more than CPTUI.

    You’re not going to want to try and force the language part into the rewrite slug for your post type, as that’s going to create more havoc than you intend. That field is meant just for replacing “products” alone in the url, or whatever one may use as the post type slug. You could make the URL use “gift” instead of “products” if you wanted, but it’s only for that segment between the /’s that the field is meant for.

    All because each part of the URL is giving detail to WordPress for what should be retrieved from the database.

    Thread Starter ZioChicco

    (@ziochicco)

    Hi Michael Beckwith, thanks for your prompt reply.

    What do you really mean with

    make the URL use “gift” instead of “products”

    and how this could solve the problem?

    Thank you again!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    No, that’s not a solution here, just an example of what the custom rewrite slug field is intended for and how it can be used.

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

The topic ‘Can not display translated version of CPTs’ is closed to new replies.