- Status
- Resolved by author
- Related plugin/theme
- CozyStay
- Topic tags
- Compatibility
Overview of the issue
In the CozyStay theme, translating alt-texts for gallery images using WPML doesn’t work as expected. Despite translating the alt-texts through the Advanced Translation Editor (ATE), the translated alt-texts do not appear on the frontend for the translated pages.
Workaround
Please, make sure of having a full site backup of your site before proceeding.
- Open your theme’s functions.php file.
- Add the following code:
// WPML Workaround for compsupp-7616 add_filter('elementor/frontend/before_render', 'wpml_compsupp7616_filter_image_gallery_widget'); function wpml_compsupp7616_filter_image_gallery_widget($element) { if ('cs_gallery' !== $element->get_name()) { return; } $settings = $element->get_settings(); if (isset($settings['gallery']) && is_array($settings['gallery'])) { foreach ($settings['gallery'] as $key => $image) { if (isset($image['id'])) { $post_type = get_post_type($image['id']); if (!$post_type) { continue; } $settings['gallery'][$key]['id'] = apply_filters('wpml_object_id', $image['id'], $post_type, true); } } $element->set_settings('gallery', $settings['gallery']); } }