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.
Tagged: Exception
This topic contains 5 replies, has 0 voices.
Last updated by Otto 7 months, 1 week ago.
Assisted by: Otto.
| Author | Posts |
|---|---|
| October 6, 2025 at 12:57 pm #17460745 | |
|
lorenzo |
Background of the issue: Symptoms: Questions: |
| October 6, 2025 at 3:33 pm #17461368 | |
|
Otto |
Hello, There is no standard feature to keep the translated taxonomies in sync. This workaround may help, though: - In WPML → Settings → Taxonomy Translation, set your user taxonomy to Not translatable, so there is only one canonical set of terms site-wide. - Display localized labels (term names) via String Translation or custom gettext filters, while the underlying term remains the same across languages. This removes the need to mirror relationships; the same term applies to all languages, and only the label changes. Best Regards, |
| October 7, 2025 at 1:07 pm #17463930 | |
|
lorenzo |
Hello, and thank you for support. I dont understand the second point: Thank you |
| October 7, 2025 at 3:03 pm #17464329 | |
|
Otto |
Hello, I am sorry I wasn't clear enough. As explained, there is no way to keep taxonomies automatically in sync. You'll need to send the content to translate again in order to make the change in the other language. So, I suggested setting the taxonomy as not translatable and translate the labels using string translation. This will need some coding and will depend on how the taxonomy labels are used in your template. This will need some custom coding that it's outside the scope of our support. I was just pointing a possible solution. Best Regards, |
| October 8, 2025 at 8:39 am #17466300 | |
|
lorenzo |
Hello Otto, |
| October 8, 2025 at 12:42 pm #17467316 | |
|
Otto |
Hello, Sure 🙂 But take into account that this is just an idea. The feature you need is not a standard WPML so I am just sharing this to illustrate what I mean, I didn't test it nor we can't implement it nor maintain it. As suggested, set the taxonomy as not translatable. Then, register each term’s display label as a translatable string When a term is added/updated, register its default-language name with WPML String Translation. Then you’ll provide the label for each language there.
add_action('created_my_tax', 'my_tax_register_label_string', 10, 2);
add_action('edited_my_tax', 'my_tax_register_label_string', 10, 2);
function my_tax_register_label_string( $term_id, $tt_id ) {
$term = get_term( $term_id, 'my_tax' );
if ( is_wp_error( $term ) || ! $term ) return;
// Register the default label as a string.
do_action(
'wpml_register_single_string',
'User Taxonomy Labels', // context
"my_tax_term_{$term->term_id}_name", // name
$term->name // value (default language)
);
}
Go to WPML → String Translation, filter by context “User Taxonomy Labels”, and add translations for each my_tax_term_{ID}_name. In order toutput the localized label instead of $term->name Create a helper you’ll use wherever you display user terms:
function my_tax_label( WP_Term $term, $lang = null ) {
// Optional: force a language; otherwise WPML uses current lang.
if ( $lang ) do_action( 'wpml_switch_language', $lang );
$label = apply_filters(
'wpml_translate_single_string',
$term->name, // fallback
'User Taxonomy Labels',
"my_tax_term_{$term->term_id}_name"
);
if ( $lang ) do_action( 'wpml_switch_language', null ); // restore
return $label ?: $term->name;
}
In the front end, you'll need to use it this way: If you already have code that prints $term->name, just replace it with my_tax_label( $term ). Best Regards, |