Background of the issue:
I am trying to use Elementor Loop 'Alternate Template' to display translations on my website. The issue can be seen on this page: hidden link
Symptoms:
Elementor Loop 'Alternate Template' is not using the translation and is showing German instead of the expected English/Czech translation.
Questions:
Why is the Elementor Loop 'Alternate Template' not displaying the correct translation?
How can I ensure the Elementor Loop 'Alternate Template' shows the English/Czech translation instead of German?
Thank you for the updates, I can see the problem. I've also checked in very much detail as well as some workaround taken from an existing report. But none of this seems to work so far.
However, I need more time on this to check a few other solutions. I'll get back to you on Monday.
- Add the following code in your current theme's functions.php file:
// WPML Workaround for compsupp-6865
add_filter('elementor/frontend/before_render', 'wpml_compsupp6865_filter_loop_grid_widget');
function wpml_compsupp6865_filter_loop_grid_widget($element) {
if ('loop-grid' !== $element->get_name()) {
return $element;
}
$settings = $element->get_settings();
if (!isset($settings['alternate_templates']) || !is_array($settings['alternate_templates'])) {
return $element;
}
$alternate_settings = $settings['alternate_templates'];
foreach ($alternate_settings as $key => $value) {
if (empty($value['template_id']) || !is_numeric($value['template_id'])) {
continue;
}
// Use apply_filters to adjust template_id for WPML
$id = apply_filters('wpml_object_id', $value['template_id'], get_post_type($value['template_id']), true);
if (!is_numeric($id)) {
continue;
}
// Update the template_id in alternate_settings
$alternate_settings[$key]['template_id'] = $id;
}
// Update the settings with the modified alternate_templates
$settings['alternate_templates'] = $alternate_settings;
$element->set_settings('alternate_templates', $settings['alternate_templates']);
}
- Save the file.
- Clear all caches and recheck.
I've applied this code in your staging site's Hello Elementor Child theme's functions.php file and it solved the problem. Please check at hidden link and hidden link.
When you apply this on your live site, please remember to take full backup of your site and database beforehand.
I had the same issue, and added code, started working! Thanks!
Manage Cookie Consent
We use cookies to optimize our website and services. Your consent allows us to process data such as browsing behavior. Not consenting may affect some features.
Functional
Always active
Required for our website to operate and communicate correctly.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
We use these to analyze the statistics of our site. Collected information is completely anonymous.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
These cookies track your browsing to provide ads relevant to you.