• Resolved andrejcremoznik

    (@andrejcremoznik)


    I want something like this:

    register_post_type('post', [
      // irrelevant args
      'rewrite' => ['slug' => __('post', 'myi18ndomain')]
    ]);

    This probably won’t work because post is a built-in post type and is impossible to re-register. I didn’t bother testing though.

    What this would allow me to have is:

    /post/english-post/
    /objava/slovenian-post/

    Is creating a new post type just to have this the way to go?

    • This topic was modified 6 years, 5 months ago by andrejcremoznik. Reason: formatting
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Post type slugs are not intended to be translated because they are supposed to be used internally only. However, as you know, custom post type slugs turn up in permalinks. I would suggest placing a rewrite rule in .htaccess that takes any possible Slovenian post type names and rewrites them as the actual English post type slug.

    OTOH, if the Slovenian posts will always be just that, with no English translation also as part of post content, having a separate Slovenian post type will also work.

    I suppose it depends on how you manage the two languages in posts, together or separate.

    Thread Starter andrejcremoznik

    (@andrejcremoznik)

    I’ve done some more testing and it seems I’ve misunderstood this feature for a long while. At best it’s possible to have a translated url slug on a single-lang site. On multilang sites where the $locale is actually dynamic it will never work.

    I’ll see what I can do with rewrite rules in WP or server.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to i18n the URL slug for built in post type?’ is closed to new replies.