Skip Navigation

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

Problem:
The client was experiencing an issue where the language switcher in the menu was not correctly pointing to the respective language versions of the pages. In some cases, both PT (Portuguese) and EN (English) links were pointing to the English version, despite having both language versions of the pages available.

Solution:
1. We asked the client to provide examples of the pages where the issue occurred and to upload screenshots showing the translation settings for these pages.
2. We inquired if the issue persisted when all other plugins were deactivated, leaving only WPML active.
3. We checked if the Custom Post Type (CPT) was made translatable in WPML → Settings → Custom post translation and if the specific custom post was translated.
4. We requested information on how the CPT was created and suggested testing the language switcher in the footer to see if the same issue occurred.
5. We advised the client to test passing a non-variable to the 'rewrite' argument in their CPT definition:

'rewrite' => array('slug' => 'book'),

If you're experiencing a similar issue, we recommend following these steps to diagnose and resolve the problem. However, please note that the solution might be irrelevant due to being outdated or not applicable to your case. We highly recommend checking 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 issue 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 9 replies, has 2 voices.

Last updated by Andrey 2 months, 2 weeks ago.

Assisted by: Andrey.

Author Posts
January 30, 2024 at 4:13 pm #15245580

abelM

Hello.

I've made the switcher link to apply to my menu, with two languages PT and EN
On many pages the switcher is working correctly: PT is linking to Portuguese versions, and EN to English's.

But in some special cases PT points to EN, as well as the EN link.

I'm sure I have both page language versions.

How come is this happening?

Thank you in advanced.
AMP

January 30, 2024 at 9:26 pm #15246564

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

Thank you for contacting WPML support.

Can you show me a few examples of such pages? Please also upload some screenshots showing how these pages were translated.

Does the issue happen if you temporarily turn off all the plugins except WPML?

February 2, 2024 at 9:44 am #15258302

abelM

Dear Andrey

You may take a look to the following link:

hidden link

where you're able to change from PT to EN
but here a film page:

hidden link

the PT and EN link are not pointing to the correct language.

When hovering/clicking the EN link you should see/go to: hidden link

So why in pages the switcher is working fine and in posts (this is a custom post type to be correct) it doesn't?

Thank you.
AMP.

February 3, 2024 at 3:47 pm #15262402

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

Thank you for providing additional information. I understand the issue you are facing now.

Have you made your Custom Post Type (CPT) translatable in WPML → Settings → Custom post translation? Have you translated a particular custom post?

Could you please also explain how you created your CPT? Additionally, what would happen if you temporarily added the language switcher to the footer in WPML > Languages? Do you see the same behavior?

February 5, 2024 at 9:15 am #15264862

abelM

Hi Andrey

I have the "Post Types Translation" for "filmes" and "pessoas" set to "Translatable
use translation if available or fallback to default language".
You may confirm in the attached image.

I've created my CPT as a plugin, with the following settings:
$filmes_rewriteCPT = array(
'slug' => 'filmes',
'with_front' => false,
);

$filmes_argsCPT = array(
'label' => __( 'Filmes', 'baannng-aavpl-filmes' ),
'description' => __( ' ' ),
'labels' => $filmes_labelsCPT,
// Features this CPT supports in Post Editor
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'revisions','post-formats', 'page-attributes'),
'hierarchical' => true,
// 'taxonomies' => array('categorias_de_filmes', 'etiquetas_de_filmes'),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_icon' => plugins_url( 'icon.svg', __FILE__ ),
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'rewrite' => $filmes_rewriteCPT,
'capability_type' => 'post',
);

Finally how do I add the language switcher to the footer?

Captura de ecrã 2024-02-05, às 09.06.15.png
February 5, 2024 at 5:54 pm #15267897

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

Thank you for the update.

To add the language switcher, please navigate to WPML → Languages → Footer language switcher.

Can you please also test passing a non-variable to the 'rewrite' argument? For instance:

'rewrite' => array('slug' => 'book'),
Languages-‹-WCML-Plugin-GUI-—-WordPress(2).png
February 8, 2024 at 9:57 am #15280336

abelM

Hello Andrey.

I've activated the Switcher at the Footer and is working correctly! Why is this happening this way? I need the header switcher not in the footer!

About the Rewrite:
- if you noticed the CPT code above is divided in two parts: the rewrite which has two arguments, the 'slug' and 'with_front'. The rewrite is then called in next args part. So the suggestion you pointed about the slug is already done in the code.

February 8, 2024 at 10:04 am #15280377

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

Thank you for the update. I suspect an issue with the language switcher in the menu, as the default in the footer works as expected. How did you add it to the menu?

February 9, 2024 at 12:15 pm #15286043

abelM

Dear Andrey

I won't take your time any longer.
I found the solution.
The switcher was being added to the main menu which was a PT version of it. For some reason it didn't understand that there was a second language for the link.

So I added the switcher using a widget to the same header, then I styled it and it is working.

If you know any solution for this buggy menu just let us know.

Thank you.
AMP.

February 10, 2024 at 6:44 pm #15288943

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

I'm happy to hear that the issue has been resolved. As I suspected, it was related to the language switcher. If you have any new questions, please open a new ticket for each question. Have a wonderful weekend!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.