Home›Support›English Support›[Resolved] Browser language redirect prevent us from viewing other languages
[Resolved] Browser language redirect prevent us from viewing other languages
This thread is resolved. Here is a description of the problem and solution.
Problem: You are experiencing issues with the browser language redirect in WPML, where it redirects every time you try to view a page in a different language from the browser language, instead of just the first time. Solution: If you notice the issue resolves when switching to a standard theme, it suggests that the custom theme may be causing the problem. We recommend asking your theme developer to review and possibly comment out any custom functions related to redirecting that might be interfering with WPML's expected behavior. If you require further assistance with the custom code, consider hiring a professional from our list of recommended contractors at https://wpml.org/contractors/.
Please note that this solution might be outdated or not applicable to your specific case. We highly recommend checking related known issues at https://wpml.org/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 at our support forum.
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.
Background of the issue:
I am trying to enable the browser language redirect but only if translations exist. The issue can be seen on this page: hidden link. I want to be able to view this page when I access it directly or switch to it from the other language.
Symptoms:
The redirect works, but it should only redirect the first time. Instead, it redirects every time I try to view a page in another language that is different from the browser language.
Questions:
Why does the browser language redirect not allow viewing pages in other languages after the first redirect?
How can I configure the redirect to only occur the first time?
Thanks for the screencast. I continued clicking, switching language, and clicking more and was able to reproduce it. The first thing to rule out is caching - please disable all caching (server side, browser, caching plugins, etc) and see if the issue is still happening. If it is, we will need to test minimal settings, meaning only WPML plugins active with a default theme. This is best tested in a staging site. If you don't have one, you can use something like WP Staging to create one, or we can create one for you and migrate your site there. Just let me know which you prefer. If you already have staging, please disable all plugins except WPML, switch to a default theme such as Twenty Twenty Four and let me know if the issue is still happening.
I switched to the Twenty Twenty-four theme and it looks like I can't reproduce the issue any longer so probably there's a bug in our theme since I didn't disable any plugins. Do you have any advice on how to track this down or particular terms/functions/scripts/... I should look for that could cause this issue?
Which theme were you using previously? If it is a child theme, first check to see what custom functions may have been added. You can try commenting out any custom functions and see if it works as expected.
We're using a custom developed theme so there could be some functions messing op the redirects. I'm not sure what I should look for and it would take too much time to disable them all one by one
IF the issue is resolved when switching to a standard theme, then it is pretty clear that there is something in the custom theme causing an issue. It is outside the scope of WPML to support custom code, so I would suggest asking the developer to take a look at the custom functions and temporarily comment out any that could be related to redirecting. If you need further assistance with the custom code, we have some contractors that are able and willing to assist. https://wpml.org/contractors/