Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
Unable to translate the alt text for 'property images' from English to German using the Media Translation feature in WPML. Despite changing the alt text in the Media Translation and Real Estate sections, the frontend displays the English alt text instead of the German alt text, and the backend reverts to the English alt text after saving.
Solution:
This issue is due to a compatibility problem with the Houzez theme. We have implemented a workaround by adding the following code to the functions.php file of your theme:

add_filter('get_post_metadata', 'wpml_compsupp7300_filter_fave_property_images', 10, 4);
 
function wpml_compsupp7300_filter_fave_property_images($null, $object_id, $meta_key, $single) {
     
    // Target the specific meta key
    if ($meta_key !== 'fave_property_images') {
        return $null;
    }
 
    // Prevent recursion by temporarily removing the filter
    remove_filter('get_post_metadata', 'wpml_compsupp7300_filter_fave_property_images', 10);
 
    // Fetch the original meta value
    $images = get_post_meta($object_id, $meta_key, $single);
 
    // Re-add the filter
    add_filter('get_post_metadata', 'wpml_compsupp7300_filter_fave_property_images', 10, 4);
 
    // Check if we actually got an array
    if (is_array($images)) {
        foreach ($images as &$image_id) {
            // Apply the WPML filter to each item (image ID)
            $image_id = apply_filters('wpml_object_id', $image_id, 'attachment', true);
        }
    }
 
    return $images;
}

Please ensure to perform a full site backup before applying this workaround. For more details on this issue, refer to the errata page at https://wpml.org/errata/houzez-property-media-images-not-showing-translated-alt-text/.

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 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. Additionally, you can open a new support ticket for further assistance at WPML support forum.

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.

Tagged: 

This topic contains 18 replies, has 2 voices.

Last updated by Bigul 4 weeks, 1 day ago.

Assisted by: Bigul.

Author Posts
October 10, 2024 at 3:00 pm #16275956

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

Thank you for the updates. Please check the following post on the sandbox site. It is showing the translation for the image inserted inside the post after I translated it from the WPML Translation Editor.

hidden link

Please check the attached images for more details and let us know your feedback.

--
Thanks!

Bigul

2024-10-10_20h29_36.png
2024-10-10_20h02_05.png
2024-10-10_20h01_00.png
October 10, 2024 at 4:04 pm #16276409

markusP-25

Thanks for checking. Unfortunately, that doesn't solve the problem. The picture you put in. This is not the right position for images. Only the property description should go there. Please take a look at the screenshot. Under "properties" and then under "media", that's where the images should be and the alt text doesn't work there. And the "features image". You can see everything in the screenshot.
I created a new property for this. Here are the links:
English: hidden link
France: hidden link

Maybe it's best to find a solution with Houzez support. It's in Houzez's interest that it works. Houzez also says that WPML works 100%. Unfortunately, Houzez refers me to WPML when it's WPML related.
I'm surprised that I'm apparently the first customer to notice this. Alt text is important for SEO.

Thanks

alt problem.png
October 14, 2024 at 3:56 pm #16287125

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

Sorry for the late response becuase of the holidays. We are still working on this issue and get back to you soon. Please wait.

--
Thanks!

Bigul

October 22, 2024 at 6:31 am #16315190

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

We are getting the expected result on the sandbox site after adding the following code in the functions.php file of the theme.

add_filter('get_post_metadata', 'wpml_compsupp7300_filter_fave_property_images', 10, 4);

function wpml_compsupp7300_filter_fave_property_images($null, $object_id, $meta_key, $single) {
    
	// Target the specific meta key
    if ($meta_key !== 'fave_property_images') {
        return $null;
    }

    // Prevent recursion by temporarily removing the filter
    remove_filter('get_post_metadata', 'wpml_compsupp7300_filter_fave_property_images', 10);

    // Fetch the original meta value
    $images = get_post_meta($object_id, $meta_key, $single);

    // Re-add the filter
    add_filter('get_post_metadata', 'wpml_compsupp7300_filter_fave_property_images', 10, 4);

    // Check if we actually got an array
    if (is_array($images)) {
        foreach ($images as &$image_id) {
            // Apply the WPML filter to each item (image ID)
            $image_id = apply_filters('wpml_object_id', $image_id, 'attachment', true);
        }
    }

    return $images;
}

This issue is happening because of a compatibility issue. So we have released an errata for this. Refer to this URL for more details - https://wpml.org/errata/houzez-property-media-images-not-showing-translated-alt-text/

Please try this workaround after a full site backup {mandaotry} on your site and let us know your feedback.

--
Thanks!

Bigul

October 23, 2024 at 9:57 am #16321155

markusP-25

This problem has been solved. Thank you for being so supportive.
Bigul and the WPML team did a great job.