Skip Navigation

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

Problem:
You are trying to filter query loops by terms in Elementor when WPML is active. The filtering works in the Elementor editor but not on the live site, causing all data to be displayed instead of only the entries from the specified term.

Solution:
We recommend modifying a function in the WPML plugin to ensure correct term filtering on the live site. Follow these steps: https://wpml.org/forums/topic/wpml-ignores-loop-grid-terms-filter/#post-17022087

If this solution does not resolve your issue or seems outdated, please check the related known issues and confirm that you have installed the latest versions of themes and plugins. If the problem persists, we highly recommend opening a new support ticket for further assistance.

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: 

This topic contains 3 replies, has 0 voices.

Last updated by Shekhar Bhandari 3 weeks ago.

Assisted by: Shekhar Bhandari.

Author Posts
May 8, 2025 at 4:52 am

michaelB-173

Background of the issue:
I am trying to filter query loops by terms when WPML is active. The filtering works in the Elementor editor but not on the live site. This issue affects Loop Grids and Loop Carousels. You can see the issue on this page: hidden link

Symptoms:
All data is displayed instead of only the entries from the term limited. The filtering works in the Elementor editor but not on the live site.

Questions:
Why does the terms filter not work on the live site when WPML is active?
How can I ensure that only entries from the term limited are displayed on the live site?

May 8, 2025 at 5:51 am
May 8, 2025 at 7:21 am #17010030

Shekhar Bhandari
WPML Supporter since 03/2015

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello,

I am writing to inform you that I have escalated the issue to our second-tier supporters. I will update you as soon as I receive any feedback or suggestions from them.

Thank you,

May 12, 2025 at 10:11 am #17022087

Shekhar Bhandari
WPML Supporter since 03/2015

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Our 2nd tier supporter checked the issue and suggested the following workaround:

- Go to .../wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/core-api/core/Convert/Ids.php

- Replace the functions public static function convert with the following

public static function convert( $ids, $elementType = null, $fallbackToOriginal = false, $targetLang = null ) {
		$isId = function( $id ) {
			return is_numeric( $id ) && ! is_float( $id );
		};

		$getElementType = self::selectGetElementType( $elementType );

		/**
		 * @param int|string|mixed $id
		 *
		 * @return int|string|null|mixed
		 */
		$convertId = function( $id ) use ( $isId, $getElementType, $fallbackToOriginal, $targetLang ) {
			/** @var \SitePress $sitepress */
			global $sitepress;

			if ( ! $isId( $id ) ) {
				return $id;
			}
			$term = get_term($id);
			if ($term) {


			$convertedId = $sitepress->get_object_id( $id, $getElementType( (int) $id ), $fallbackToOriginal, $targetLang );

			if ( $convertedId ) {
				return is_string( $id ) ? (string) $convertedId : $convertedId;
			}

			return null;
		} else {
				$term = get_term_by('term_taxonomy_id', $id);
				$convertedId = $sitepress->get_object_id( $term->term_id, $getElementType( (int) $term->term_id ), $fallbackToOriginal, $targetLang );

				if ( $convertedId ) {
					$convertedterm = get_term($convertedId, $getElementType( (int) $convertedId ));
					if ($convertedterm) {
						$convertedId = $convertedterm->term_taxonomy_id;
					}
					return is_string( $id ) ? (string) $convertedId : $convertedId;
				}

				return null;
			}

		};

		try {
			return $isId( $ids )
				? $convertId( $ids )
				: Obj::over( self::selectLens( $ids ), $convertId, $ids );
		} catch ( \Exception $e ) {
			return $ids;
		}
	}

Let me know if this helps.

Thanks

May 13, 2025 at 7:40 am #17025564

michaelB-173

Perfect, that works.
Will this fix be included in the next official release of WPML or do I have to patch the file after every update?

May 13, 2025 at 7:45 am #17025603

Shekhar Bhandari
WPML Supporter since 03/2015

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello,

This feature will be included in the upcoming releases, but I can’t promise it’ll be the next one. In the meantime, you can check the change-log or I’ll update this post when it’s released.

Thanks