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


Leave a Reply

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