This thread is resolved. Here is a description of the problem and solution.
Problem:
If you're experiencing issues where the translated captions in an image slider are not displayed and instead show the default language captions, even though they are translated in the translation editor.
Solution:
First, ensure that you have the latest versions of Elementor and JetElements plugins installed. Next, you need to add custom PHP code to your theme's functions.php file to handle the translation of image captions in sliders. Here is the code you should insert:
function translate_gallery($metadata, $object_id, $meta_key, $single){
$meta_needed = 'gallery';
if ( isset( $meta_key ) && $meta_needed == $meta_key ){
remove_filter( 'get_post_metadata', 'translate_gallery', 100 );
$current_meta = get_post_meta( $object_id, $meta_needed, TRUE );
$to_translate = explode( ',', $current_meta );
foreach ( $to_translate as $key => $value ){
$to_translate[$key] = apply_filters( 'wpml_object_id', $value, 'attachment', true );
}
add_filter('get_post_metadata', 'translate_gallery', 100, 4);
$current_meta = implode( ',', $to_translate );
return $current_meta;
}
return $metadata;
}
add_filter( 'get_post_metadata', 'translate_gallery', 100, 4 );Additionally, modify the Jet Engine plugin's code to ensure compatibility with WPML. In the file \wp-content\plugins\jet-engine\includes\classes\tools.php, after line 792, add the following code:
if ( is_numeric( $img_data ) ) {
$id = $img_data;
} elseif ( is_array( $img_data ) && isset( $img_data['id'] ) && isset( $img_data['url'] ) ) {
$id = $img_data['id'];
} else {
$id = attachment_url_to_postid( $img_data );
}Add the following
// WPML Workaround for wpmlsupp-12960
if ( class_exists('Sitepress') ) {
$current_lang = apply_filters( 'wpml_current_language', NULL );
$id = apply_filters( 'wpml_object_id', $id, 'attachment', TRUE, $current_lang );
}If this solution does not resolve your issue or becomes irrelevant due to updates, we 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 problem persists, 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.
This topic is split from https://wpml.org/forums/topic/translate-media-meta-fields-jetengine/
This topic contains 13 replies, has 0 voices.
Last updated by 9 months, 2 weeks ago.
Assisted by: Kor.