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 6 replies, has 2 voices.

Last updated by fernandoF-12 1 month, 3 weeks ago.

Assigned support staff: Alejandro.

Author Posts
August 23, 2019 at 10:05 am

fernandoF-12

I am trying to:
Use language switcher on header menu, but it only works on homepage, on all other pages it does not change the language. All pages are translated. There is another switcher in the footer that works fine on every page, so this issue is only related to the header switcher.

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

What have i done already:
Cleared and disabled WPML Cache, tried manually add language switcher with

 icl_get_languages('skip_missing=N&orderby=KEY&order=DIR&link_empty_to=str') 

Notes: footer language switcher always works on all pages, header language switcher only works on homepage.

No need to request access as I already provide access details in form below and have already made a backup of my site. You can install any plugin that you find necessary for this ticket.

August 23, 2019 at 10:40 am #4445927

Alejandro
Supporter

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

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

Hello and welcome to WPML Support forum.
I'm Alejandro and I'll be helping you out today.

Before I access the site I'd like to ask you a few questions:

1) did this happen all suddenly, I mean, if it used to work and it doesn't now or if it hasn't worked since the beginning?

2) I also want to ask if you can please increase your WordPress memory to 256M if possible.

To do that you just have to edit the wp-config.php file of your installation and add the following code after the database information:

define('WP_MEMORY_LIMIT','256M');

Thus is because it's possible that the site is using more memory than allocated for WordPress and that's why it can render the language switcher anywhere else.

3) in what file did you add the code for the language switcher?

4) can you confirm you followed this documentation: https://wpml.org/documentation/getting-started-guide/language-setup/custom-language-switcher/

Let me know so I can understand how to proceed.

August 23, 2019 at 11:11 am #4446283

fernandoF-12

1) it never worked, this issue exists since I've installed WPML

2) Memory limit is already at 1G

3) in functions.php and on header.php on child-theme but I have removed it since it didn't solved the problem. Currently the header language switcher is setup via WPML language settings...see screenshot

4) yes, I've followed the guide and I've done this many times before without any problems.

August 23, 2019 at 11:55 am #4446579

Alejandro
Supporter

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

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

The memory you're referring to is the server's memory allocation (php memory which in WordPress is used as WP_MAX_MEMORY_LIMIT)

The one I asked about is the memory allocated to the WordPress installation which is a bit different.

Could you please increase it and let me know?

Another thing I note from your answer is that usually when you add the code yourself, you should enable "custom language switcher" instead of the menu language switcher. So try that as well, please (and delete the menu language switcher you are showing in the screenshot above).

I'll access your site and inspect it in the meantime.

Regards.

August 23, 2019 at 2:48 pm #4448249

fernandoF-12

Hello,
i've increased memory limit as per your request.

About custom language switcher I was trying to avoid that because it will force me to restyle my header to place in custom switcher in the right place.

Your menu language switcher is already in the right place and it is working fine on home page but not on other pages.
Can you help me make the header menu switcher work on all pages?
Maybe missing something because footer switcher is working fine on all pages too.

August 23, 2019 at 5:09 pm #4448979

Alejandro
Supporter

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

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

Ok the problem is happening because of either the ND Shortcodes plugin or WP bakery (i'm 90% sure it's because of ND Shortcodes but i can't test one without the other).

the most interesting fact, though is that the problem involves the theme as well. so it seems the problem is conflicting with something in the theme that then conflicts with WPML because i tested WPML and that plugin (same version and the same version of WP Bakery as well) and it worked fine there.

As soon as you disable the plugin OR deactivate the current theme, everything works well.

So i went ahead and checked the debug log for clues and found nothing which means the problem is most likely on your theme's code and i suspect it will be in the same place where you added this code:

icl_get_languages('skip_missing=N&orderby=KEY&order=DIR&link_empty_to=str')

I would suggest you comment that code (i couldn't find it, because i wanted to do that myself) because, the menu language switcher shouldn't need that.

if that doesn't solve the issue then i would suggest you look at maybe a code that is retrieving the home URL or maybe the current URL, because the problem could be over there.

I'm only asking this because it seems you have customized the theme, but if that's not the case,

Then upload both the plugin and ND shortcode plugin in this sandbox site and try to recreate the problem there (i.e: translate a few pages and add a menu language switcher. see if the problem is being replicated there)

Sandbox site: hidden link

please do not migrate the entire site, just the necessary plugins and theme, this test will help me make sure the problem is a compatibility issue and for that to work, it needs to be on a very minimal base.

Regards.

August 27, 2019 at 10:27 am #4465181

fernandoF-12

I solved the issue on my own creating custom language switcher. Typical plugin author saying is theme's fault and theme author saying is plugin's fault and none of them solving the problem. Anyway I still recommend WPML as the best translation plugin.