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.

Our next available supporter will start replying to tickets in about 2.35 hours from now. Thank you for your understanding.

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

Problem: I am trying to use wpml_add_language_selector on date archive page to switch between English (EN, default) and Spanish (ES), but the language switcher is returning only links for the current language, whether it is EN or ES.

Solution: Switching to a default WP theme helped pinpoint the cause of this problem, as the WP theme did not use all the custom Roots theme features, so I concentrated on the Roots-specific features and identified the Roots Soil plugin as a possible cause since it employs relative URL rewrites.

Disabling the relative URL rewrite from the Roots Soil plugin fixed the language switcher problem on the date archive pages. The language switcher works on the other pages, as per normal, even with the relative URL rewrite disabled.

Relevant Documentation:

This topic contains 9 replies, has 3 voices.

Last updated by Carlos Rojas 5 months, 4 weeks ago.

Assigned support staff: Carlos Rojas.

Author Posts
April 16, 2019 at 9:58 am

Gerry

I am trying to:
Use wpml_add_language_selector on date archive page to switch between English (EN, default) and Spanish (ES), but the language switcher is returning only links for the current language, whether it is EN or ES.

Link to a page where the issue can be seen:
EN - hidden link
ES - hidden link

I expected to see:
To be able to switch between EN and ES on the date archive pages

Instead, I got:
I cannot switch between EN and ES. If I am on the EN date archive page, I cannot switch to ES, and vice-versa.

The language switcher works on the category archive pages, however.

April 16, 2019 at 9:00 pm #3625685

Carlos Rojas
Supporter

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

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

Hello,
Thank you for contacting WPML support.

Could you describe the steps you are following in order to add the title for this archive page?

E.g.:
- Reubicación a Londres y más allá! (ES)
- Relocation to London and beyond! (EN)

Kind regards,
Carlos

April 17, 2019 at 1:15 pm #3631085

Gerry

Thanks for your response, but I'm not sure I follow you.

The title on the archive page is a string translation of the WP tagline -- there is nothing wrong with that. Does string translation affect the language switcher?

My issue is with the language switcher, as per the title of this ticket.

On the date archive pages, such as:
hidden link - date archive in EN
hidden link - date archive in ES

The language switcher is not returning the correct links that will allow me to switch between EN and ES.

Hover on the language switcher links 'English' and 'Espanol' on the above two links (see attached PNG)

On hidden link both the 'English' and 'Espanol' links return only the English link. I cannot switch to Spanish.

On hidden link both the 'English' and 'Espanol' links return only the Spanish link. I cannot switch to English.

Hope this is a clearer explanation of the problem.

April 17, 2019 at 2:53 pm #3632137

Carlos Rojas
Supporter

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

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

Hi there,
Thank you very much for your message.

I asked to you the steps to edit the title of the archive to see if I could find a way to link the language of the archive with the title. I'm aware of the issue and I was able to reproduce it on the site ????

I consulted our specialists and there could be two potential causes for this issue:
1.- The custom language switcher. You can see a working example of a regular language switcher added to the menu: hidden link

2.- The posts are set to 'display as translated'. To change this settings you need to go to WPML -> Settings -> Post types translation -> Set the posts to 'only show when translated' option -> Save the changes.

Could you tell me if changing one or both of the configuration above solves the issue?

Best regards,
Carlos

April 17, 2019 at 4:12 pm #3632583

Gerry

Thanks for your response.

For future reference, please explain your logic whenever you ask me to do something ... simply asking "Could you describe the steps you are following in order to add the title for this archive page?" does not give me assurance that you had understood my question.

My concern is we have a language barrier between us, so please try to be more careful when explaining what you want me to do and be exact when describing steps.

I visited WPML -> Settings -> Post types translation, and I believe you want me to select the option "Translatable - only show translated items" ... so I selected that for posts, and clicked on the Save button.

I then checked the date archive pages and still see that the problem with the language switcher as described in my earlier responses is not solved.

The link you provided seems to be for a Unyson framework on the TwentySeventeen theme, so it does not seem to be applicable for my setup. I assume that that link uses the latest WPML plugin versions, yes?

For the language switcher, I used the following in the template:

do_action('wpml_add_language_selector');

I had customised the output via WPML -> Languages -> Custom language switchers -> Customize

If you view the date archive pages on your mobile phone, the mobile menu language switcher also shows the same problem.

I had customised the output of the menu language switcher via WPML -> Languages -> Menu language switcher.

Hope these help.

April 17, 2019 at 8:26 pm
April 18, 2019 at 2:01 pm #3639753

Gerry

Thanks for your reply.

A copy of the site has been migrated to your proposed test server, so you can continue with your tests there.

Hope to hear from you again soon!

April 19, 2019 at 4:22 pm #3647505

Alejandro
Supporter

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

Timezone: Europe/Rome (GMT+02:00)

Hello, my name is Alejandro,

Since Carlos is currently not available, I will replace him here in the forum until he gets back.

I hope this is OK with you.

I isolated the problem and it turns out the problem is somewhere in the theme. as soon as i disable it, the problem goes away.

I tried to search for the customization that you mention (the action that you're adding) but i couldn't find where it was, would you kindly tell me where can we find it?

By the way, in the staging site, the theme has been changed to the default one (temporarily) so you can check for yourself what i mean, by accessing this page: hidden link

April 19, 2019 at 7:06 pm #3648047

Gerry

It's ok with me as long as a solution is found.

The wpml_add_language_selector do_action is found in the client's custom theme, so you won't find it after switching to a default theme.

themes/securelybe/templates/header.php
themes/securelybe/templates/header-home.php

Do let me know what the next steps are now that it seems it could be the client's custom Roots theme that is somehow affecting the language switcher URLs. Thanks!

April 19, 2019 at 7:55 pm #3648139

Gerry

For my reference

Switching to a default WP theme helped pinpoint the cause of this problem, as the WP theme did not use all the custom Roots theme features, so I concentrated on the Roots-specific features and identified the Roots Soil plugin as a possible cause since it employs relative URL rewrites.

Disabling the relative URL rewrite from the Roots Soil plugin fixed the language switcher problem on the date archive pages. The language switcher works on the other pages, as per normal, even with the relative URL rewrite disabled.

----

Thanks, Carlos and Alejandro, for helping me pinpoint and fix the problem!

April 22, 2019 at 12:46 pm #3655735

Carlos Rojas
Supporter

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

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

Hi there,

I'm glad to hear that the issue is solved 🙂

Please don't hesitate to contact us if you need our help in the future with WPML. We will be more than happy to help.
Best regards,
Carlos