How to localize custom post type permalink – WordPress

If you develop WordPress multi-sites for multi language purposes I’m sure you’ve encountered this problem.

How do I localize/translate the slug on my custom post types?

Say you have your register post type function for books:

As you can see, we’ve defined the “slug” to be “books“, so the URL for this posts type on all your sites (EN, FR, ES…) will be ““.

That might be fine if you don’t use the post type in the frontend (public). In my case I want different URL’s for each site:

  • EN:
  • ES:


Add a custom option to the Permalinks page under the Settings in the WordPress admin.

This neat plugin works flawlessly, give it a try:

1) Create a cpt-permalinks.php inside your /wp-content/plugins folder.

2) Paste the following code inside the file.

Original GitHubGist

3) You can customize the text by translating the string “CPT Base” or, if your admin is only in one language just change the string in the code.

4) Now change your register custom post type function to use the value from this new field:

Extra: yes, you could also paste the plugin code inside your theme’s functions.php file, it’s up to you.

Permalink Settings

This is how your permalinks settings page will look like:

custom post type permalink

6 Responses to “How to localize custom post type permalink – WordPress”

  1. Hugo March 14, 2014 at 7:09 pm #

    Is that me or this will only give you the option of changing the slug (and not translate it) :

    will become :

    • Rick March 15, 2014 at 1:05 pm #

      Nope! Since this option is stored by site you can set it different in each site.

      Say you you go to the /en/wp-admin and set it to books and then to the main site /wp-admin and set it to libros.

      Let me know if this helps.

  2. Ady September 25, 2014 at 5:26 pm #

    Thank you so much , I ‘m two hours trying to solve this problem.

  3. Hasi Steinbeiss March 3, 2017 at 12:43 pm #

    Hey Ricard, i thank you so much!!
    Great work. *thumbs up*

    • Rick March 3, 2017 at 12:45 pm #

      You’re welcome!

  4. Albert December 3, 2017 at 11:37 am #

    Moltíssimes gràcies Ricard!
    Una solució brillant!

Leave a Reply

Add <code> Some Code </code> by using this tags.