Background of the issue:
I am trying to use the language switcher on my WordPress site hidden link. I want to switch between LV and LT languages. I have used the following code: define( 'WP_SITEURL', 'hidden link' . $_SERVER['HTTP_HOST'] ); define( 'WP_HOME', 'hidden link' . $_SERVER['HTTP_HOST'] );
Symptoms:
When I click on the LV language, I get redirected to LT (default). If I manage to access amberglow.lv, I cannot switch back to LT language. Clicking on the Lithuanian language redirects to LV.
Questions:
Why does the language switcher redirect to the default language?
How can I switch back to the LT language from LV without redirection issues?
Welcome to the WPML support forum. I will do my best to assist you in resolving the issue.
As shown in the following screenshot, the Latvian language is currently set to be hidden, so it won’t be accessible on the frontend:
hidden link
However, as an admin user, you can still access it by enabling the "Display hidden languages" option in your profile under Users >> Profile >> WPML language settings.
After taking a site backup, enable the “Display hidden languages” option, save the changes, clear all types of caches, and check if the issue still exists.
Thats not the issue. I know how to access hidden language... Did you actually checked screenshot ? Because you should see in latvian language both languages are with same domain... Lithuanian (default) amberglow.lv and Latvian (second language) amberglow.lv as well. But if I checking in Lithuanian language wp admin I see correct domains. Lithuanian - Amberglow.lt , Latvian - Amberglow.lv
it doesn't matter if language is hidden or not, I still getting same issue. If I try to access amberglow.lv I cannot because doesn't work. If I add wp-config code I provided in my question I can access but then I cannot go back to Lithuanian language. From LT to LV I can but from LV to LT I cannot because both URLs are same (amberglow.lv) for some reasons...
Thank you for the updates. Please try the following steps after taking a full site backup, and check if you are getting the expected results:
- Log in to the site using the default language domain
- Go to WPML >> Languages >> Language URL format
- Under A different domain per language, select the option “Auto sign-in and sign-out users from all domains”
- Save the changes
- Go to Settings >> Permalinks, and click Save Changes
- Clear all types of caches (plugin, server, and browser)
For more information, please refer to the following documentation and the related support ticket.