Skip to content Skip to sidebar

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

Problem:
The client was trying to use the auto-translate feature to translate their website's content, including custom post types like "building". They expected internal links to be fully translated, including the custom post type slugs. However, the slug for a specific custom post type was not being translated correctly in the links.

Solution:
1. The client resolved the issue by changing the "original" language of their custom post types to Spanish, which is the main language of their website.
2. They then reset the permalink structure, which resulted in the internal links being properly translated.

We also recommended:
- Ensuring that linked pages are translated and published.
- Editing and saving the original page with the links, then updating its translations.
- Navigating to WPML > Settings and using the "Scan Now and adjust links" button in the "Translate Link Targets" area.
- Updating WPML and String Translation plugins to the latest versions for bug fixes and enhancements.

If you're experiencing a similar issue and the solution provided here is not applicable or outdated, we recommend checking the related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket with us.

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.

Tagged: 

This topic contains 22 replies, has 2 voices.

Last updated by Prosenjit Barman 1 year, 4 months ago.

Assisted by: Prosenjit Barman.

Author Posts
March 6, 2024 at 7:35 pm #15381355

guillermoC-9

Hello Prosenjit,

While waiting for an update on this issue I tried to run some tests on my end, which I would like to share with you in case they can help you and your team move forward with the investigation.

In you last message you mentioned "identified some issues with the code on the Single Post page". In order to test this I switched the site to a WP default theme, recreated my CPT (which are created by my theme) with a plugin, and attempted to translate some content.

The issue still persisted, so as far as I can tell, it is unrelated to the theme.

I hope this helps and I'll keep waiting for an update on your end.

Thanks!

March 7, 2024 at 8:21 am #15382610

Prosenjit Barman
WPML Supporter since 03/2023

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hello There,
Thank you so much for the update.

One of our developers from our second-tier team has conducted an in-depth analysis of the problem and identified a potential workaround. This solution requires a few modifications, so please follow the provided steps closely and execute them in a staging environment or take a full backup of the site or database if you're trying them on your production site.

- Please go to: wp-content/themes/wikiarquitectura6/single-building.php
- Find the following line:

$architects = get_field('architect');

and add the code below after the line:

foreach ($architects as $key => $value) {
    $architects[$key] = apply_filters( 'wpml_object_id', $value, 'architect' );
}

Note: You should find that line twice in the code, make sure to do the same for both lines.
- After that, Install and activate the "WPML Sticky Links" plugin on your site. You can download the plugin from your WPML Account(https://wpml.org/account/downloads/)
- Then, update the original post, which will allow you to convert the posts' links to IDs. Make sure that the link in the contents remains as: Walter Netsch
- After that, go to "wp-content/plugins/wpml-string-translation/classes/slug-translation/" and open the "class-wpml-slug-translation.php" file.
- Comment out the following line of code:

! ( $ld = $this->sitepress->get_element_language_details( $post->ID, 'post_' . $post->post_type ) )

Note: you may notice some error messages due to commenting on the code. Please be informed that the error is expected as we commented out a function call.
- Update the translation of the post again and the links should appear correctly after that.

For your information, the internal ticket as also been escalated to the core development team for further investigation. Please try the workaround and let me know if that helps. We will be happy to help if you need further assistance in this matter.

Best regards,
Prosenjit

March 18, 2024 at 10:53 am #15420452

guillermoC-9

Hello Prosenjit,

I just wanted to ask for an update on this ticket. Whenever you can, no rush. Thanks! πŸ™‚

March 19, 2024 at 4:02 am #15424020

Prosenjit Barman
WPML Supporter since 03/2023

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hi There,
I hope you're doing well.

It seems you have missed an update sent on March 7th that included a potential solution to this problem. Here's the link to the message from that day: https://wpml.org/forums/topic/autotranslate-is-not-translating-the-slug-of-custom-post-types-in-content-links/page/2/#post-15382610

Could you give the suggested workaround a try to see if it resolves the problem? Please feel free to let me know if you need further assistance in this matter. I will be happy to help.

Best regards,
Prosenjit

March 19, 2024 at 10:56 am #15425722

guillermoC-9

Hi Prosenjit,

I saw that message, but to be honest, and as much as I appreciate the time you and your team are putting into this, that hardly sounds like a solution... even as a workaround it seems to me like the risk of performing all those steps and messing something up are higher than the potential reward, which again would not be a solution, and I would still face the same problem whenever I translate more articles after that.

I understand I don't have the knowledge you and your team have about how your plugin works, but it stands out to me that you guys keep pointing to the theme as the problem, when to me the theme is just a way to layout and style the information. As far as I can tell all the translated content lives in the database, and should be properly translated there. How the theme could interfere with the translation process is something I don't fully understand. Plus, as I said in a previous message, I tried switching to a default WP theme and the translation problem still persists, so it's hard to believe the problem is related to the theme.

That's how I see the issue from my end, but of course any insight you can give me into why you guys think differently is greatly appreciated, I'm here to learn from you πŸ™‚

March 20, 2024 at 5:47 am #15429429

Prosenjit Barman
WPML Supporter since 03/2023

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hi There,

Thank you for your honest feedback. I understand your concerns and appreciate your patience.

Regarding the theme, we realize it might not be the root cause, especially since the issue persists with a default WP theme. Our initial focus on the theme aimed to thoroughly investigate all potential variables, but based on your feedback, we are now adjusting our focus accordingly.

For a more straightforward approach, I suggest adjusting the sticky link plugin as outlined in my last response. Please also ensure that internal links are formatted correctly (e.g., `Walter Netsch`). This solution showed positive results in our tests and might work for your site as well.

Please ensure your site and database are fully backed up before making any changes. Your understanding is valuable to us and I also have forwarded your feedback to the team. We're here to assist every step of the way.

Best regards,
Prosenjit

April 2, 2024 at 7:08 pm #15474886

guillermoC-9

I managed to fix the problem.

In case someone finds this thread in the future, this is what was going on.

I had declared my Custom Post Types in English, meaning I gave them an English name and an English slug.

As you can see in the image I attached to the first message of this thread, English was set as the "original" language for the CPT slugs in the WPML settings.

However, the main language of my website was set to Spanish.

I changed the "original" language of my CPT to Spanish, reset the permalink structure, and internal links are now properly translated.

Thank you Prosenjit and the rest of the WPML team for your assistance.

πŸ™‚

April 3, 2024 at 4:42 am #15475875

Prosenjit Barman
WPML Supporter since 03/2023

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hello There,
I hope you're doing well.

I'm glad to hear that you've successfully resolved the issue. The approach you've taken to solve the issue is certainly commendable and thank you for sharing the solution with the community! This will certainly help others who might encounter a similar problem.

I will also ensure to add the solution to the "Solution Box" right after you mark the ticket as resolved! πŸ™‚

Feel free to reach us if you ever need any assistance with our plugins. We will be happy to help.

Once again, Thank you so much for sharing the solution and your kind cooperation throughout this matter.

Best regards,
Prosenjit