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.

Our next available supporter will start replying to tickets in about 2.97 hours from now. Thank you for your understanding.

Tagged: 

This topic contains 16 replies, has 2 voices.

Last updated by Long Nguyen 9 months, 1 week ago.

Assisted by: Long Nguyen.

Author Posts
July 24, 2023 at 1:24 am #14085349

Long Nguyen
Supporter

Languages: English (English )

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

Hi,

I got a workaround from the 2nd tier support, please check it below:

- IMPORTANT: Please backup your database and website before proceeding
- Add the code below to the file functions.php in the theme/child theme folder

// WPML Workaround for compsupp-6865
add_filter( 'elementor/frontend/before_render', 'wpml_compsupp6865_filter_loop_grid_widget');

function wpml_compsupp6865_filter_loop_grid_widget($element) {
	if ( 'loop-grid' !== $element->get_name() ) {
		return;
	}

	$settings = $element->get_settings();

	if ( isset( $settings['post_query_posts_ids'] ) && is_array( $settings['post_query_posts_ids'] ) ) {
		
		// post_query_posts_ids
		foreach ( $settings['post_query_posts_ids'] as $key => $id ) {      

			$post_type = get_post_type( $id );

			if ( ! $post_type ) {
				continue;
			}

			$id = apply_filters( 'wpml_object_id', $id, $post_type, true );

			unset($settings['post_query_posts_ids'][$key]);
			$settings['post_query_posts_ids'][] = $id;
		}

		// Query by terms
		foreach ( $settings['post_query_include_term_ids'] as $key => $id ) {      

			
			$taxonomy = 'category';

			$term = get_term($term_id);			

			if ($term instanceof WP_Term) {
				$taxonomy = $term->taxonomy;
			} 

			$id = apply_filters( 'wpml_object_id', $id, $taxonomy, true );

			unset($settings['post_query_include_term_ids'][$key]);
			$settings['post_query_include_term_ids'][] = $id;

		}

		// Update the settings
		$element->set_settings( 'post_query_posts_ids', $settings['post_query_posts_ids'] );
		$element->set_settings( 'post_query_include_term_ids', $settings['post_query_include_term_ids'] );
	}
}

- Edit the page in the original language (English on your site) > Make a small change to the content > Save > Update the translation.

It will fix this issue in two cases: Query Manual Selection and Query Include by term.

Look forward to your reply.
Thanks

July 24, 2023 at 8:43 am #14087289

oguzhanA

Hello,

I had a quick look after adding the code:
hidden link

I think on my site the original language of this page is now German, that's why when I try to edit in English, it switches to German. I think there must be some kind of indication if I try to edit a post in the wrong language and offer to switch to the original language.

So I could not test this properly, but I trust that you already tested it as you found the issue in the test site. Could you let me know if I have to keep the code indefinitely in the functions.php or if this will be incorporated into a future update?

July 24, 2023 at 9:39 am #14087727

Long Nguyen
Supporter

Languages: English (English )

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

Hi,

This issue has been escalated to our development team and it will be included in a future update. I will update you here once I have any information.
Meanwhile, you can keep the code in your theme/child theme folder if you create the page in the second language (English).

Thanks for your patience.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.