Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
If you're experiencing issues with manually translated product attributes adding an extra slug in the URL, which causes filters in other languages to not work correctly, especially when using the Kadence theme with WooCommerce and the Query Loop, this summary might help.
Solution:
We recommend modifying the code in your Kadence Blocks Pro plugin to handle the attribute translations more effectively. Here are the steps:
1. Open the file

/wp-content/plugins/kadence-blocks-pro/includes/query/query-indexer-woo.php

.
2. Locate line 74.
3. Replace the
Replace:

				if ( ! empty( $attribute_values ) ) {
					$attribute_values_array = explode( ',', $attribute_values );
					foreach ( $attribute_values_array as $facet_name ) {
						$facet_name = trim( $facet_name );
						$term = get_term_by('name', $facet_name, $tax_name);

						if ($term) {
							$term_id = $term->term_id;
						}

						$rows[] = array(
							'facet_value' => isset( $term_id ) ? $term_id : 0,
							'facet_name'  => $facet_name,
							'facet_id'    => isset( $term_id ) ? $term_id : 0
						);
					}

					return $rows;
				}

With:

if ( ! empty( $attribute_values ) ) {
					$attribute_values_array = explode( ',', $attribute_values );
					foreach ( $attribute_values_array as $facet_name ) {
						$facet_name = trim( $facet_name );
						$term = get_term_by('name', $facet_name, $tax_name);

						if ($term) {
							$term_id = $term->term_id;
						}
						//WPML workaround for compsupp-7812
						$languages = apply_filters( 'wpml_active_languages', NULL);
    					if ( !empty( $languages ) ) {
							foreach( $languages as $language ){
								$term_id = apply_filters( 'wpml_object_id', $term_id, $tax_name, TRUE, $language['language_code'] );

								$rows[] = array(
									'facet_value' => isset( $term_id ) ? $term_id : 0,
									'facet_name'  => $facet_name,
									'facet_id'    => isset( $term_id ) ? $term_id : 0
								);
							}
						}
					}

					return $rows;
				}

4. After making these changes, go to your default language product and click update to create a re-index for the loop.

Please note that this solution might become outdated or may not apply to your specific case. If this solution does not resolve your issue, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket.

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.

This topic contains 18 replies, has 0 voices.

Last updated by patrykP-6 2 days, 11 hours ago.

Assisted by: Dražen.

Author Posts
January 24, 2025 at 12:25 pm #16631293

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

please try next workaround
Open the /wp-content/plugins/kadence-blocks-pro/includes/query/query-indexer-woo.php file

Look for line 74

Replace:

	if ( ! empty( $attribute_values ) ) {
					$attribute_values_array = explode( ',', $attribute_values );
					foreach ( $attribute_values_array as $facet_name ) {
						$facet_name = trim( $facet_name );
						$term = get_term_by('name', $facet_name, $tax_name);

						if ($term) {
							$term_id = $term->term_id;
						}

						$rows[] = array(
							'facet_value' => isset( $term_id ) ? $term_id : 0,
							'facet_name'  => $facet_name,
							'facet_id'    => isset( $term_id ) ? $term_id : 0
						);
					}

					return $rows;
				}

With:

if ( ! empty( $attribute_values ) ) {
					$attribute_values_array = explode( ',', $attribute_values );
					foreach ( $attribute_values_array as $facet_name ) {
						$facet_name = trim( $facet_name );
						$term = get_term_by('name', $facet_name, $tax_name);

						if ($term) {
							$term_id = $term->term_id;
						}
						//WPML workaround for compsupp-7812
						$languages = apply_filters( 'wpml_active_languages', NULL);
    					if ( !empty( $languages ) ) {
							foreach( $languages as $language ){
								$term_id = apply_filters( 'wpml_object_id', $term_id, $tax_name, TRUE, $language['language_code'] );

								$rows[] = array(
									'facet_value' => isset( $term_id ) ? $term_id : 0,
									'facet_name'  => $facet_name,
									'facet_id'    => isset( $term_id ) ? $term_id : 0
								);
							}
						}
					}

					return $rows;
				}

- Go to your default language product and click update, just so re-index is created for loop

Regards,
Drazen

January 29, 2025 at 11:24 pm #16648912

patrykP-6

Hi! I'm back with some feedback. I added the code, updated the products, and everything worked beautifully! Today, I added the "32" attribute to one product. It appears in the list of attributes for filtering (and disappears when I remove it), but it doesn’t work in any language. I tried:

- removing and re-adding the attribute
- updating the product multiple times
- synchronizing all products via WPML
- checking the code to ensure it wasn’t overwritten (it’s fine)

After all these steps, filtering for this newly added (previously existing) attribute still doesn’t work in any language.

Do you have any ideas on what else I can do?

January 29, 2025 at 11:40 pm #16648933

patrykP-6

Aaa, it's only the newly added attribute to the existing product that isn’t working (the attribute itself already existed and was even added to the product, but no variant was generated). The attribute was added to the product, added in all languages, and is displayed on the product page. It also appears in the filter list, but it doesn't work. The rest of the products continue to work after adding the codes and updating.

January 30, 2025 at 7:11 am #16649568

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

I suggest checking without WPML, since if it doesn't not work in any language, then it might not be related to WPML.

Let me know how it goes.

Regards,
Drazen

February 1, 2025 at 4:31 pm #16658619

patrykP-6

Okay, I identified the problem, because when I deleted the attribute "32" in the native language, it wasn't automatically removed in other languages, which led to complications. After deleting it in every language and recreating it, everything works fine.

So, I'm closing the topic, the issue seems to be resolved. If I discover anything else, I’ll let you know.

Thank you for your help! 🙂