Skip Navigation

[Resolved] How to change Archive slug

This thread is resolved. Here is a description of the problem and solution.

Problem:
The user needed to change the slug of an archive page from "autoclave-comparator" to "comparador-de-autoclaves" and later wanted to translate this slug into multiple languages using WPML. However, she faced difficulties in finding the setting to change the slug and translating it for different language versions.
Solution:
We instructed them to change the slug by editing the custom post type in Toolset under the Rewrite settings. Later, when they wanted to translate the archive slug for different languages, we explained that WPML only allows the archive slug to be translatable if it matches the 'rewrite['slug']' or the custom post type name slug. This means the archive slug must be the same as the slug for single posts or the post type name for it to be translatable in WPML.
Relevant Documentation:
https://wpml.org/documentation/support/translating-slugs-for-custom-post-type-archives/

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

This topic contains 6 replies, has 3 voices.

Last updated by Mateus Getulio 6 months, 2 weeks ago.

Assisted by: Mateus Getulio.

Author
Posts
#2696224

The slug of this archive page hidden link has been changed by mistake to "autoclave-comparator" when it should be "comparador-de-autoclaves".

The problem is that I cannot find where the slug can be changed. 3 months ago I had been answered the same question (https://toolset.com/forums/topic/how-to-change-page-archive-slug/) and I had found the answer easy, whereas now I don't seem to understand it...

I hope you can help me out...

Thank you in advance

#2696262

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screenshot 2024-05-07 at 13.04.55.png

Hi there

Normally the archive URL is formed using the slug of the post type.

You can change it when registering the custom post type, and specify something else.

Go to Toolset > Post types and edit your custom post type.

Expand the Options section and update the Rewrite settings (screenshot).

The same setting will be used as the slug to display individual posts of that custom type, as well as for the archive.

#2696277
Screenshot 2024-05-07 at 15.17.59.png

Thank you very much Nigel!

That was it...
I now have a doubt though: how can I assign a different slug in other languages?

If I understand correctly, the custom archive slug cannot be translated (https://wpml.org/documentation/support/translating-slugs-for-custom-post-type-archives/), but I hope there is a way out aomehow, since I cannot leave the same spanish slugs for all the other languages...

Apparently in the String Translations it's possible to add a translation, but it doesn't seems to be working...

Is there a possible solution for this?

Thank you

#2696311

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello Maria,

Yes, it is possible to translate the CPT slug with WPML, although you want to try it in a different place rather than String Translation.

I've set up a sandbox environment and tested the steps described here and it worked for me:
https://wpml.org/documentation/getting-started-guide/translating-page-slugs/#translate-url-slugs-wpml

Can you please give it a try to see if you're able to translate that custom slug with the steps described in that article?

Thank you, please let us know.
Mateus

#2696357

Hi Mateus,

thank you for your reply. I am afraid your suggestion it's not what I am looking for, as I am not trying to translate de CPT slug, but the CPT archive slug...

Is there a way to do that?

#2696358
Screenshot 2024-05-08 at 09.00.36.png
Screenshot 2024-05-08 at 08.59.43.png

Hi Mateus,

thank you for your reply. I am afraid your suggestion it's not what I am looking for, as I am not trying to translate de CPT slug, but the CPT archive slug...

See the attached screenshots: I am not trying to translate "modelos" but "comparador-de-autoclaves"...

Is there a way to do that?

#2696592

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi,

I'm sorry for the confusion and thank you for sharing even more information.

I just double-checked with my colleagues and I'm afraid that there is a limitation in WPML where the slug of the archive can only be translatable if it's equal to the slug for single posts. Similarly to what you mentioned in one of your messages.

"WPML allows has_archive to be set to a string. However, if the string value is set to something other than rewrite['slug'], or the custom post type name slug is not set, the archive slug will not be translatable.": https://wpml.org/documentation/support/translating-slugs-for-custom-post-type-archives/

It means that in order to make the archive slug translatable, it must match the 'rewrite['slug']' or the custom post type name slug.

Regards,
Mateus