Skip Navigation

Open

Topic Tags: Compatibility

Overview of the issue

When using the Houzez theme, property media images added via the Media section do not display translated ALT text on the translated property 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 snippet:
    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;
    }
    

Leave a Reply

Please stay on topic and be respectful to others. If you need help with issues not related to this post, use our Support Forum to start a chat or submit a ticket.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>