Skip to content Skip to sidebar

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.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 -
- 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by Long Nguyen 1 year, 3 months ago.

Assisted by: Long Nguyen.

Author Posts
April 25, 2024 at 8:24 am #15564090

sebastianB-9

I am on WPML Version 4.6.10 and this error is occurring again: https://wpml.org/errata/wp-6-0-issues-with-terms-assigned-to-posts/

April 25, 2024 at 9:54 am #15564532

sebastianB-9

so, rather this is the ticket which fits my issue: https://wpml.org/forums/topic/assigning-non-default-language-term-result-in-assigning-default-language-term/

It's not duplicating the translated terms, but rather it is assigning the default language term to the translated post even though i give the translated term ID wit wp_set_post_terms.

Example:

Base Language: German

German Post ID: 1
English Post ID: 2

taxonomy name: test

German Term ID: 1001
English Term ID: 1002

the terms and posts are correctly translated.

i now call the following code:
// set german post terms
wp_set_post_terms( 1, array(1001), 'test', false );
// set english post terms
wp_set_post_terms( 2, array(1002), 'test', false );

if i check in the backend afterwards, the german post will have the term assigned, the english post will show no terms.

In the DB we can see that:

- german post has 1001 assigned => correct
- english post has 1001 assigned => false, should be 1002 like i've given in the set_post_terms call

April 26, 2024 at 8:51 am #15569386

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

I can replicate the issue on the sandbox site. The translation term ID is assigned to both posts in German and English, table wp_term_relationships.

I'm discussing the issue with our 2nd tier support and I will update you here when I have something to share.

Thanks for your patience.

May 9, 2024 at 2:21 am #15608131

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

I got some information from our 2nd tier support. This issue is related to the Auto Adjust ID feature of WPML, where WPML adjusts the IDs to current languages. There are two workarounds to fix this issue:

1. Go to WPML> Languages > Make themes work multilingual > Disable option "Adjust IDs for multilingual functionality".

2. (Recommend) Remove the WPML filters temporarily and add them back after adding the terms:

- Add this function to the functions.php file

function wpmlsupp_11681_adjust_term_filters( $add = false ) {
		global $sitepress;

		if ( ! $sitepress instanceof SitePress ) {
			return;
		}

		if ($add == true) {
			add_filter( 'get_term', array( $sitepress, 'get_term_adjust_id' ), 1, 1 );
			add_filter( 'terms_clauses', array( $sitepress, 'terms_clauses' ), 10, 3 );
		} else {
			remove_filter( 'get_term', array( $sitepress, 'get_term_adjust_id' ), 1 );
			remove_filter( 'terms_clauses', array( $sitepress, 'terms_clauses' ), 10 );
		}
}

use the function in the code that sets the post term

add_action( 'init', function() {
		wpmlsupp_11681_adjust_term_filters();

		wp_set_post_terms( 60, [9], 'category', false );
		wp_set_post_terms( 62, [10], 'category', false );
		
		wpmlsupp_11681_adjust_term_filters(true);
}, 20 );

❌ IMPORTANT: Please backup your database and website before proceeding ❌
If you want to check this on a sandbox site, please click on this link, you will be redirected to the admin area directly
hidden link

Looking forward to your reply.
Thanks

The topic ‘[Closed] I am on WPML Version 4.6.10 and this error is occurring again’ is closed to new replies.