Background of the issue:
I am trying to translate property listings using WPML in a WordPress website built with the WpResidence theme. When a listing is translated, WPML duplicates the featured image. This behavior only happens on the translated versions of the listings. The original listings display images correctly. Link to a page where the issue can be seen: hidden link
Symptoms:
The translated listing shows the featured image twice: once as the main image and again as part of the image gallery.
Questions:
Why is the featured image duplicated in the translated listings?
How can I prevent the featured image from appearing twice in the translated listings?
Thanks for reaching out. I can see the duplicated image on your primary language listing. To check if this is related to WPML, could you please deactivate WPML and create a new listing? Let me know if the issue still occurs afterward.
Hi, I've been investigating the issue of the duplicated featured image in translated listings when using WP Residence with WPML, and I believe I’ve identified the exact source of the behavior.
Here’s what I tested:
I created a new listing in English with a featured image and a gallery.
Then I translated that listing into Spanish.
Immediately after the translation, the featured image appeared twice in the translated version — once as the main image (as expected), and again within the gallery.
This behavior happens consistently every time a translation is created. However, I noticed something interesting:
I edited an already translated listing, deleted all the images (including the featured image), and uploaded new ones.
After saving, the translated listing no longer showed the duplicated image. The featured image was displayed correctly, and it was not repeated in the gallery.
This suggests the issue doesn’t come from the theme or the frontend rendering, but rather from what happens at the moment WPML creates the translation. Specifically, it appears that when WPML copies the featured image from the original listing, it also includes it as a gallery attachment — possibly because the featured image from the original post is treated as an attachment and isn't filtered out when duplicating.
Additionally, I tested the following:
I went to WPML → Media Translation and disabled the option “Duplicate featured images for translated content.”
After that, when creating new translations, the featured image was no longer assigned automatically, which prevented the duplication issue in the gallery.
However, now the entire gallery gets duplicated — all images from the original gallery are copied and attached again, but the featured image field in the translated listing is left empty and has to be manually assigned.
This confirms:
If WPML duplicates the featured image → it appears twice (featured + gallery).
If WPML does not duplicate it → the featured image is missing in the translation, and the gallery is duplicated anyway.
Could you please confirm whether WPML includes the featured image as a regular attachment when duplicating a listing?
And is there any way to prevent that image from being inserted into the gallery while still keeping it correctly assigned as the featured image in the translated post, without having to edit every listing manually?
Thanks for your reply. Duplicating the featured image should not display both on the listing. Something is wrong there and I will need to closely examine your website. Therefore, I will require temporary access (WP-Admin and FTP) to a test site where the problem has been replicated, if possible. This will enable me to provide better assistance and determine if any configurations need to be modified.
Please note that it is important to have a backup for security purposes and to prevent any potential data loss. You can use the UpdraftPlus plugin (https://wordpress.org/plugins/updraftplus/) to fulfill your backup requirements.
Your upcoming reply will be treated with confidentiality and will only be visible to you and me.
✙ To resolve the issue, I may need your consent to deactivate and reactivate plugins and the theme, as well as make configuration changes on the site if necessary. This emphasizes the significance of having a backup.
Thanks for your reply. I’ve identified the issue on your staging site. Could you please try to replicate the same issue on our sandbox site here: hidden link
I’ve already installed the WPML plugin for you. Please go ahead and install the required theme and any additional plugins needed to reproduce the issue. Once done, let me know so I can escalate this for further investigation.
I regret any inconvenience caused, but to proceed with troubleshooting, I kindly ask for a snapshot of the site. Alternatively, with your permission, I can create one myself. For this purpose, I typically recommend using the free plugin "Duplicator." If you're already familiar with Duplicator (https://wordpress.org/plugins/duplicator/), please skip the following steps and simply send me the archive file you downloaded.
To guide you further, please adhere to these instructions:
1. View the Duplicator instructions video: hidden link
3. If the archive file exceeds 400MB, please use Duplicator's file filters to exclude cache, wp-uploads directory, media, and archive files.
Once you have the archive file ready, kindly share the link with us. You can utilize platforms like Google Drive, Dropbox, or similar for file sharing, as the snapshot file might be large.
Please note that your next reply will be private, visible only to you and me. You can paste the file link there. Rest assured that once the issue is resolved, I will delete the local site.
Thanks for your patience. I have a workaround from our 2nd Tier Support and kindly apply the fix following the steps below.
Workaround
There is no filter we can use, so you need to change their code:
Open the \wp-content\themes\wpresidence\libs\property_page_functions\gallery_functions.php file
You will find this piece of code several times in the file:
// If include_thumbnail is true, add the post thumbnail ID at the beginning of the array
if ($include_thumbnail) {
$thumbnail_id = get_post_thumbnail_id($propID);
if ($thumbnail_id) {
array_unshift($gallery_meta, $thumbnail_id);
}
}
Option 1 - You hardcode the setting to false:
// If include_thumbnail is true, add the post thumbnail ID at the beginning of the array
$include_thumbnail = false; // hardcoded to false
if ($include_thumbnail) {
$thumbnail_id = get_post_thumbnail_id($propID);
if ($thumbnail_id) {
array_unshift($gallery_meta, $thumbnail_id);
}
}
Option 2 - Get the original thumbnail ID with wpml_media_id that way when they enforce unique IDs the duplicate will be removed.
// If include_thumbnail is true, add the post thumbnail ID at the beginning of the array
if ($include_thumbnail) {
$thumbnail_id = get_post_thumbnail_id($propID);
// WPML workaround - Convert the media ID to default language.
$default_lang = apply_filters('wpml_default_language', NULL );
$thumbnail_id = apply_filters( 'wpml_media_id', $thumbnail_id, $default_lang );
if ($thumbnail_id) {
array_unshift($gallery_meta, $thumbnail_id);
}
}
The topic ‘[Closed] Featured image is duplicated in translated listings using WpResidence theme’ is closed to new replies.