Skip Navigation

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.

Elementor users - please update WPML to the latest version to maintain compatibility. More details here - https://wpml.org/changelog/2024/12/wpml-4-6-15-critical-update-for-elementor-sites/
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: America/Los_Angeles (GMT-08:00)

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Bobby 5 days, 2 hours ago.

Assisted by: Bobby.

Author Posts
November 8, 2024 at 8:25 pm #16383475

juliaR

Background of the issue:
I am trying to use the 'Copy taxonomy to translations' functionality with custom post types in WordPress. When using the WordPress Editor, the terms assigned to the original post are not being copied over to the translation. The functionality works fine with the 'post' post type. The 'Copy taxonomy to translations' setting is enabled, and the terms have been translated. I tested this on the 'twentytwentyfour' theme and encountered the same issue.

I did some digging and I believe the `add_hooks` method in the class `WPML_REST_Posts_Hooks` runs before custom post types are registered (before the 'init' action), so the hooks aren't being applied to them.

Symptoms:
Terms are not copied over to translations for custom post types, despite the setting being enabled and terms translated.

Questions:
Can this be fixed.

November 9, 2024 at 12:17 am #16383688

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Hello,

I escalated this thread to our 2nd tier support and they will take a look at this issue.

You will be notified as soon as new information is available.

Thank you,
Bobby

December 24, 2024 at 4:51 pm #16544309

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Hi there,

Please try the following workaround.

1. Take a backup before proceeding

2. Go to your theme's functions.php and add the following code

function fixposttype() {
	global $sitepress, $wpml_term_translations;
	$post_type = "movie";
	$test      = new WPML_REST_Posts_Hooks( $sitepress, $wpml_term_translations );
	add_filter( "rest_prepare_$post_type", array( $test, 'prepare_post' ), 10, 2 );
}

fixposttype();

Once added, try again and the issue should be resolved.

Let me know your results, please.