Skip Navigation

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

Problem:
ACF custom taxonomy (i.e. using %season% as a URL tag in permalinks) slug translation not working.

Solution:
It turns out that unlike standard permalink tags (i.e. %postname%, %category%, %post_id% and etc), the %season% is a custom permalink tag. Thus it needs to be incorporate and be handled using custom code.

Unfortunately, custom coding is out of scope of this forum. However, following these examples, you can use to register your custom URL tag in WordPress and achieve the purpose. Please see the following articles:

- https://shibashake.com/wp/add-custom-taxonomy-tags-to-your-wordpress-permalinks
- https://wordpress.stackexchange.com/questions/301167/add-or-create-custom-structure-tags-to-permalink

Besides these, if you would want to extend the functionality (optional) from above mentioned articles, you can use WPML Hooks (https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/).

Alternate Solution: (Shared by WPML User)
"After installing the following free version of the plugin, one is able to set the desired translations at the plugins settings and the links work properly now:
https://wordpress.org/plugins/permalink-manager/"

Relevant Documentation:
- https://shibashake.com/wp/add-custom-taxonomy-tags-to-your-wordpress-permalinks
- https://wordpress.stackexchange.com/questions/301167/add-or-create-custom-structure-tags-to-permalink
- https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/

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.

This topic contains 8 replies, has 2 voices.

Last updated by Waqas Bin Hasan 1 year, 5 months ago.

Assisted by: Waqas Bin Hasan.

Author Posts
November 14, 2023 at 4:33 pm #14800853

Orfeas

Wordpress
WPML
ACF
ACFML

All latest updates used in a development site.
I have created a CPT (Traditions / Δρώμενα) and custom taxonomy (Season / Εποχή).
I have designated custom urls for the cpt and the taxonomy in ACF.
English (primary) language permalinks work properly, However when switching to Greek I get a url that leads to a 400 error.

Parents work properly:
hidden link
translates to
hidden link

Taxonomy archive page also translates properly
hidden link
hidden link

However when clicking on the custom post type itself I get an error as the /%season%/ part of the custom url defined in the acf advanced tab for the CPT does not translate correctly.
hidden link
and the error
hidden link

instead of

hidden link

I have tried to translate the url - slug through:
WPML->settings-> slug translations (check)
WPML->settings->Post Types Translation->Traditions (traditions)->Set different slugs in different languages for Traditions->thrace/traditions/%season% (english original) -> thraki/dromena/%season% (greek translation)
I suspect the problem is that when translating custom taxonomy "Season" through WPML->Taxonomy translation there is no option for the slug.
Please help and if it is too complicated for me to explain here I would gladly give you access to this development site.
Thank you

November 16, 2023 at 7:38 am #14822373

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting the support.

That % based identifiers 'll not work for CPT and taxonomy translations, when translating through WPML (out of the box). I discussed with the team and found that the % implies that there is an additional logic that would replace the variable - and this may require custom coding (which is unfortunately out of the scope of this forum).

However, I recommend to translate each part separately instead of thrace/traditions/%season% (a / based long path + % based notation). For example, CPT's slug thrace -> thraki, taxonomy's slug traditions -> dromena and child term autumn -> fthinoporo.

You can translate each taxonomy term accordingly, please see these guides for details:

- https://wpml.org/documentation/getting-started-guide/translating-post-categories-and-custom-taxonomies/
- https://wpml.org/documentation/getting-started-guide/translating-page-slugs/

I hope this clarifies the situation.

Regards.

November 16, 2023 at 8:49 am #14823049

Orfeas

Translating the slugs without custom slugs defeats the whole purpose of the desired structure becausa that way custom taxonomies have different paths than CPTs.

Sorry if I didn't make it very clear. I will try to define everything more precisly so you could get a better idea of what I am trying to achieve:
hidden link = page
hidden link = subpage
hidden link = custom taxonomy "season"
hidden link = custom post type "tradition"
I have achieved this url structure by defining
ACF->Post Types->Traditions->Advanced settings->URLs->Permalink Rewrite=Custom Permalink + URL slug=thrace/traditions/%season%

ACF->Taxonomies->Seasons->Advanced settings->URLs->Permalink Rewrite=Custom Permalink + URL slug=thrace/traditions/
This allows to have the following structure:
home/page/subpage/custom taxonomy/cpt
(home/thrace/traditions/season/tradition)
Primary language works fine but I am having trouble with the slug translation. Is there some way to call the custom taxonomy and insert it into the slug without the %.

November 16, 2023 at 12:30 pm #14826437

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for the updates.

I need to take a closer look at your site. So I request temporary access (WP-Admin and FTP), preferably to a test site where the problem has been replicated.

Your next answer will be private, to share this information safely.

Also provide detailed steps to reproduce the issue and links to pages in admin and on frontend.

IMPORTANT: Please take a complete backup of the site to avoid data loss. I may need to activate/deactivate plugins also.

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

November 17, 2023 at 10:19 am #14836523

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for the access and the details.

Unfortunately I am unable to login due to incorrect password. Please check on your side and let me know.

I've enabled your next reply as private again, in case if you need to provide new credentials.

November 17, 2023 at 1:00 pm #14862949

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for fixing the login issue. I was able to login.

I quickly checked a few things but looks like I need to work more on this. Please allow me some time and I'll get back to you on Monday.

November 20, 2023 at 7:12 am #14873305

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for your patience and cooperation.

I looked into it again and this looks a bit complex to achieve. However, I am not giving up until I am very sure. I have to discuss this again with my team and 'll get back to you accordingly.

November 20, 2023 at 7:34 am #14873437

Orfeas

Thank you Waqas for your persistance. I will be waiting to hearing from you. Hopefully with some good news. Other than that with the help of the Rankmath team I have been able to translate (through hard code snippets) their breadcrumb function so everything looks perfect except for this slug mishap.

November 21, 2023 at 5:56 am #14881689

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for your patience with me.

I discussed the matter and it turns out that unlike standard permalink tags (i.e. %postname%, %category%, %post_id% and etc), the %season% is a custom permalink tag. Thus it needs to be incorporate and be handled using custom code.

Unfortunately, custom coding is out of scope of this forum. However, I found some example which you can use to register your %season% in WordPress and achieve the purpose. Please see the following articles:

- hidden link
- https://wordpress.stackexchange.com/questions/301167/add-or-create-custom-structure-tags-to-permalink

Besides these, if you would want to extend the functionality (optional) from above mentioned articles, you can use WPML Hooks (https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/).

I hope this helps.

November 21, 2023 at 7:31 am #14882301

Orfeas

I have also found out that this is a complicated issue as is the pagination slug translation. Anyway, I will read through your suggestions and try to achieve the desired result. Thank toy for your time and effort.