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.

Tagged: 

This topic contains 8 replies, has 2 voices.

Last updated by davidH-81 1 year, 7 months ago.

Assisted by: Long Nguyen.

Author Posts
April 13, 2023 at 8:56 am #13462537

davidH-81

I'm having a problem with the WPML Language Switcher not working correctly for my Custom Post Type (CPT) entries. While switching to a different language using the language switcher works fine for regular posts and pages, the language of the CPT entries stays the same and doesn't change.

I've ensured that the custom post type is set to be translatable in the WPML Translation Management plugin, and I've also double-checked the settings for the WPML Language Switcher to make sure that it's configured correctly. Despite my efforts, the language switcher still isn't working correctly for my CPT entries. Please note that I'm using the Pods plugin.

Kindly check this link: [removed by supporter]

I would appreciate it if you could investigate this issue and provide a solution as soon as possible. Let me know if you require any additional information from my side.

Thank you for your assistance.

April 14, 2023 at 7:16 am #13471055

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi David,

Thank you for contacting WPML support, I'd be happy to help you with this issue.

It looks like the post of the post type "resources" are not translated completely. When I open the list of "resources" posts in the German language, I see there is one post available. Please check the links below
[removed by supporter]

Can you please share some screenshots of the table list of resources posts in the admin area?

Look forward to your reply.
Thanks

April 14, 2023 at 8:46 am #13471681

davidH-81

Hello,

Thank you for your response.

Please refer only to the URL slug when discussing the resource post.

The URL for the post is: [removed by supporter]

I have attached a screenshot of the list of translated resources in German for your reference.

If you change the language, you will notice that the URL slug changes from [removed by supporter]
to
[removed by supporter]

However, the "/de/" segment of the URL remains the same, which is the root of the issue. This issue also occurs when changing from /en/ to /de/.

Please avoid using the URL [removed by supporter] since it is created as a page, and the language switcher functions correctly on that page.

Lastly, please be aware that certain information discussed during our conversation is confidential and should not be shared on the support forum.

Thank you

April 17, 2023 at 1:42 am #13483027

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Thank you for your feedback.

Ok, let's focus on this post link [removed by supporter]

I see that, when hovering over the language switcher, navigate to German language, the URL is: [removed by supporter]

You can see the double slashes // where should be the translation of "bpm". I'm not sure what is the "bpm" (custom field or taxonomy) on your site but it looks a custom code to add it to the single post URL.

I suggest you can try to enable a minimal environment as below to see if it helps:
- deactivate all non-WPML plugins
- switch to a standard theme of WordPress
❌ IMPORTANT: Please backup your database and website before proceeding ❌
You can use this plugin to create the backup: 
https://wordpress.org/plugins/duplicator/

Look forward to your reply.
Thanks

April 17, 2023 at 8:39 am #13485193

davidH-81

Hello,

Apologies for the occurrence of the double slash.
This was caused by the German post being in draft mode.

In this instance, BPM has been established as a resource taxonomy, and we have implemented a code snippet to rewrite URLs from their original format of hidden link to the updated format of hidden link.

It's possible that there's a missing element in the code we added, which pertains to WPML and is obstructing the switch functionality.

Permalink Rewrite:
$permalink = get_home_url() ."resources/" . $term_slug . '/' . $post->post_name;

Kindly let me know if I can share additional information with you. As mentioned in the previous conversation, it is imperative that this chat remains confidential.

Regards!

April 17, 2023 at 9:34 am #13485857

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Thank you for your feedback.

So I understand you are using the custom code to customize the URL on your site. I would like to inform you that helping you with custom code, is out of the scope of WPML. I suggest you can try:

- resave the permalink settings (post name)
- run the function flush_rewrite_rules() at the "init" hook with a later priority to flush the rewrite rules. Please follow the documentation https://developer.wordpress.org/reference/functions/flush_rewrite_rules/

If you are not able to accomplish this, I would recommend you contact one of our certified partners that will be more than happy to help you with this. In this link, you will find a list of our certified partners: https://wpml.org/contractors/

Look forward to your reply.
Thanks

April 19, 2023 at 9:07 am #13503161

davidH-81

Hi,

I am pleased to report that the ticket problem has been effectively resolved.

Initially, we had some uncertainty regarding the appropriate WPML language parameters to incorporate into our code and requested clarification on their specific application.
Nevertheless, we were able to solve the issue independently, and no additional support was necessary.

Thank you for your timely and responsive handling of this matter.

Additionally, I noticed that I have disclosed some confidential information in the ticket which is still present. Therefore, I would like to request the deletion of the ticket.

Kind regards!

April 20, 2023 at 2:09 am #13508485

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Thank you for your feedback.

I do not have permission to delete the ticket but I removed the sensitive information in this ticket as your request.

If you see that is ok, kindly mark this ticket as Resolved. Thanks.