This thread is resolved. Here is a description of the problem and solution.
Problem:
The client is experiencing an issue where the language switcher on their website does not direct to the translated page but instead redirects randomly. This problem is due to a conflict with the WPResidence theme's caching method, which incorrectly caches the language switcher links.
Solution:
1. As a temporary fix, we recommend adding the following code to the functions.php file of your theme to clear the WPResidence menu transients on each page load, ensuring the menu updates correctly and displays the appropriate language links:
/** * Zap every WP Residence menu transient on each page load. * The target string is unique enough that a single LIKE works. */ function cleanup_wpresidence_menu_transients() { global $wpdb; $like = '%' . $wpdb->esc_like( 'wpestate_wpresidence_primary_menu_complete' ) . '%'; $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", $like ) ); } add_action( 'init', 'cleanup_wpresidence_menu_transients' );
Ensure you perform a full site backup before implementing this code. After adding the code, clear all types of caches to check if the issue persists.
2. Additionally, the WPResidence theme team has acknowledged this bug and plans to include a fix in a future theme update. Meanwhile, they suggest disabling the Theme Menu Cache as a temporary workaround. You can find instructions on how to do this here: Disable WP Residence Cache.
If this solution does not resolve your issue or seems irrelevant due to being outdated or not applicable to your case, we highly recommend checking related known issues at WPML Known Issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If needed, please open a new support ticket at WPML Support Forum for further assistance.
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.