Skip Navigation

[Resolved] Featured image is not duplicating even though all checkmarks are checked

This support ticket is created 2 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by robertA-13 2 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#2445061
WPML duplicate media options are checked.png
EN translated post has no featured image on translation.png
FR original post has a featured image.png

Tell us what you are trying to do?

Hi there, I'm having this issue where translating a CPT is copying all the custom fields but not the featured image. I could find many threads online about this problem, but the solution doesn't seem to work for us.

The issue happens when we manually create and translate a post in the WordPress dashboard AND when we create a post with a CRED form and then use the PHP action wpml_make_post_duplicates to auto translate the post.

To replicate, please do the following:
- Log into site
- Go to Annonces: hidden link
- Create a new FR post filling all the fields
- Translate the post by duplicating it (the plus sign, you may leave all images the same name)
- Go to the EN version of your new post, the featured image will be empty

We also tried debugging by PHP logging the translated post's feature image and it does seem to indeed have the correct media ID, but does not display in the WP dashboard or on the front-end post.

However, after having translated the post, if you go to the original post with a featured image and save it, the featured image will now appear on the translated post.

The settings at WPML > Media Translation are all checked.

To try and debug this, please first try by creating manual Annonce (Ad) CPT and translating them to gte the featured image to show up. This should also make our CRED hook code work.

Please take control of any page if ever it is being occupied by anyone else. Also, backups at multiple levels have been made, so no worries about that.

I will attach a couple of images of the issue.

Thanks!

Is there any documentation that you are following?

Yes. https://toolset.com/forums/topic/problem-with-feature-image-in-ads-not-copying-to-translated-version/

Is there a similar example that we can see?

Yes. https://toolset.com/forums/topic/problem-with-feature-image-in-ads-not-copying-to-translated-version/

What is the link to your site?

hidden link

#2445459

Hello,

Since it is a custom codes issue, please provide a test site with the same problem, fill below private message box with login details, also point out:
1) the problem page URL and form URL,
2) Where I can edit your custom PHP codes
I need to test and debug it in a live website, thanks

#2446853

Hi,

The corresponding code for the CRED form creating the post is in the the Snippet name "On new ad publish by user".

Have you guys had the chance to check the issue?

Thanks!

#2446931

Thanks for the details, I have done below modifications in your website:
Edit the custom code snippet "On new ad publish by user":
hidden link
add below codes in line 32~34:

 		$featured_image_id = get_post_thumbnail_id($post_id);
		$translated_id = apply_filters( 'wpml_object_id', $post_id, 'post', false, 'en' );
		set_post_thumbnail( $translated_id, $featured_image_id ); 

Please test again, check if it is fixed, thanks

#2447219

Hi Luo,

Thank you so much. This seems to have solved my issue.

Have a wonderful day!