Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

WordPress 6.7 has introduced a new issue that impact translations, please update WooCommerce and WPML to the latest versions before you report issues. More about this here - https://wpml.org/errata/php-error-wp-6-7-notice-function-_load_textdomain_just_in_time-was-called/
Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 14:00 12:00 – 14:00 12:00 – 14:00 12:00 – 14:00 12:00 – 14:00 -
- 17:00 – 21:00 17:00 – 21:00 17:00 – 21:00 17:00 – 21:00 17:00 – 21:00 -

Supporter timezone: Europe/Vienna (GMT+01:00)

Tagged: 

This topic contains 12 replies, has 2 voices.

Last updated by Bigul 3 weeks ago.

Assisted by: Bigul.

Author Posts
October 23, 2024 at 2:39 pm #16322423

Kresimir

Background of the issue:
I'm trying to translate the slug for a custom post type (CPT) called 'book'. The slug should be 'book' for the single template and 'books' for the archive template. I've followed the instructions from the WPML documentation (https://wpml.org/documentation/support/translating-slugs-for-custom-post-type-archives/).

Symptoms:
I can't find the place in the WPML settings to translate the archive slug. The settings only have a field for the singular slug, but there is no field for the archive slug, which is different from the singular.

Questions:
Where can I translate the archive slug for a custom post type in WPML?

October 23, 2024 at 5:01 pm #16322872

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

Welcome to the WPML support forum. I will do my best to help you to resolve the issue.

To help you faster, I've enabled debug information for this support ticket. Please see this link for how to get this information from your site and give it to us: http://wpml.org/faq/provide-debug-information-faster-support/

Please share the code you are using for creating the Custom Post Type. It will help us to cross-check it further.

Please note that by default we can only translate the Post Type slug from WPML>>Settings. Refer to the following similar ticket for more details.

https://wpml.org/forums/topic/archive-custom-slug-translation/#post-15610303

--
Thanks!

Bigul

October 24, 2024 at 9:34 am #16325317

Kresimir

Hey Bigul. Sorry about the double ticket. I was opening the ticket and then at the end I clicked on the wrong button and there was no way for me to find the ticket again. You can close the other one and we continue here.

October 24, 2024 at 1:44 pm #16326726

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

Thank you for the updates. No problems. I have closed the duplicate ticket now. Are managing the CPT by customized code? If so, please share the code you are using for creating the Custom Post Type. It will help us to cross-check it further.

--
Thanks!

Bigul

October 25, 2024 at 1:38 pm #16330948

Kresimir

Yes. It's registered with a plugin. Here is the contents of the plugin file: hidden link

October 28, 2024 at 7:42 am #16336081

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

Thank you for the details. Please fill in the private details fields after a full site backup{mandatory}. I would like to access the admin area of your site to check further. Refer to the following links for more details about our private information-sharing policies.

https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

hidden link

--
Thanks!

Bigul

October 28, 2024 at 4:45 pm #16339136

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

Thank you for the login information. We will test it further and get back to you as soon as possible. Please wait.

--
Thanks!

Bigul

October 31, 2024 at 2:43 pm #16352244

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

There is no exact option to translate the *has_archive* string. We officially recommend to set it as true *'has_archive' => true*.

https://wpml.org/documentation/support/translating-slugs-for-custom-post-type-archives/#setting-a-translatable-slug

We are getting the expected results on your staging site after setting the *has_archive* to true and resaving the permalinks.

Please refer to the following links for more details and let us know your feedback.

hidden link

hidden link

--
Thanks!

Bigul

November 4, 2024 at 10:13 am #16360050

Kresimir

Hey Bigul. Thank you for your reply but I don't think we understand each other.

Our clients wants the singular template to have the slug book and the archive template to have the slug books. As you can see in my plugin this functionality works as expected. This is the archive link (hidden link) and this is the singular link (hidden link).

WordPress API for registering custom post types has an option to have different slugs for the single template. You can see in the official WordPress documentation the has_archive template can be a string (https://developer.wordpress.org/reference/functions/register_post_type/). Also even WPML documentation has an example that uses that option (https://wpml.org/documentation/support/translating-slugs-for-custom-post-type-archives/#setting-the-same-slug-in-default-and-secondary-languages). As you can see in the example from your documentation the has_archive is set to my-books and the rewrite is set to array('slug' => 'book') so this is not some custom modification but we're just using the WordPress API following the documentation.

I hope that we've established that this functionality which we require is part of the WordPress API. So my question is can WPML translate those slugs seeing as this is the functionality that WordPress has built in the custom post API?

I hope I've explained my question if not let me know and I can go in more detail.

November 5, 2024 at 1:32 pm #16366958

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

Thank you for the detailed feedback. I have consulted about this with our team.

WordPress allows us to set a specific archive slug for custom post types when you register them manually. But as of now, we can only translate the Post Type slug.

Please check this example - https://wpml.org/documentation/support/translating-slugs-for-custom-post-type-archives/#setting-the-same-slug-in-default-and-secondary-languages

The examples shared in the doc like the following and we have requested *do not use the gettext functions for this parameter*.

  • English (default language): hidden link;
  • Spanish (second language): hidden link;

For the post type created with the archive slug *books*, the easiest approach would be to set has_archive => true and set the post type slug as *books*. This would allow the slug to be translated automatically across languages. In most cases, this method works well and aligns with how WordPress supports slug translation officially.

However, since you’re specifying the archive slug as 'books' instead of the default, it may require custom coding to achieve full functionality across languages.

Thank you for your kind understanding. Please let us know if you would like further assistance with this setup.

--
Thanks!

Bigul

November 5, 2024 at 4:01 pm #16368041

Kresimir

Hey Bigul. Thank you for your reply and help with this.

As for what you refer as "default" I wouldn't agree with that. There is no "default" in that sense, there is only what the WordPress API for registering custom pst type supports and the API has that option and that option works by itself. The issue is that WPML doesn't have support for that option. I presume there are no plans to implement that feature in WPML any time soon?

November 6, 2024 at 5:26 pm #16374208

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

Thank you for the details. I have shared it with our team for an expert opinion. We will get back to you as soon as possible. Please wait.

--
Thanks!

Bigul

November 8, 2024 at 7:33 am #16380781

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

I have forwarded the ticket to our second-tier team for further checking. We will get back to you as early as possible. Please wait.

--
Thanks!

Bigul