Skip Navigation

[Resolved] Search results show in different language with WPML

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

Problem:

When I visit my page, the houses display in the language this site is currently in. But when I enter a filter and search, the search results will change the language of the result to dutch somehow. I'm using WPML for translation.

The strange thing is, this only happens when you're not logged in. When I am logged in, the search results work just fine.

Solution:

The problem you mentioned above is abnormal, in case it is a compatibility problem, please try this:

1) deactivate other plugins and switch to wordpress default theme, and test again

2) After doing some more research, user found out that because of the page is reloading it's AJAX, the translation is lost. So he added some custom PHP codes to fix it:
https://toolset.com/forums/topic/search-results-show-in-different-language-with-wpml/#post-626401

Relevant Documentation:

This support ticket is created 6 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 6 replies, has 2 voices.

Last updated by Luo Yang 6 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#624853

When I visit my page, the houses display in the language this site is currently in. But when I enter a filter and search, the search results will change the language of the result to dutch somehow. I'm using WPML for translation.
The strange thing is, this only happens when you're not logged in. When I am logged in, the search results work just fine.

Link to a page where the issue can be seen:
hidden link

I expected to see:
The search results in the chosen language

Instead, I got:
The search results in Dutch

#625130

Hello,

The problem you mentioned above is abnormal, in case it is a compatibility problem, please try this:
1) deactivate other plugins and switch to wordpress default theme, and test again
2) If the problem still persists, please provide a database dump file (ZIP file) of your website in below private detail box, also point out the problem page URL, I need to test and debug it in my localhost, thanks

#625491
wpml2.JPG

Thanks for the details, here are what I found in your database dump file:
1) I tried the problem page "Pick your place" in my localhost with a fresh wordpress installation + Toolset plugins + WPML plugins, it does not output anything in the content area, it is empty,

And you are using below codes in the page content:

[siteorigin_widget class="WPV_Widget"][/siteorigin_widget]

It seems to be a shortcode from other plugin/theme, it is not the Views shortcode [wpv-view]

2) So I simple create another page, display the view "alle-woningen" directly, with views shortcode:
[wpv-view name="alle-woningen"]
test it in front-end, it works fine, see screenshot wpml2.JPG

It seems to be a compatibility problem with the shortcode [siteorigin_widget ], I suggest you create another page, and display the view shortocde directly

More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-view

#625627

Hi There,

I tried what you said, making a new page with only the

[wpv-view name="alle-woningen"]

but the problem still persisted...

#626048

There isn't similar problem with your database dump file in my localhost.

But since you are using AJAX feature in the view "alle-woningen", Please try this:
Dashboard-> WPML-> Languages
Enable "Language filtering for AJAX operations", click "Save", and test again.

If the problem still persists, please provide a test site with same problem, and fill below private detail box with login details and FTP access, I need a live website to test and debug, thanks

#626401

Hi there,

I found "Language filtering for AJAX operations" but it was already enabled so that didn't help. After doing some more research I found out that because of the page is reloading it's AJAX, the translation is lost. So I added to my php file:

if ( isset( $_GET[ 'wpml_lang' ] ) ) {
    do_action( 'wpml_switch_language',  $_GET[ 'wpml_lang' ] ); // switch the content language
}

It seems to be fixed now, thank you for your support anyway!

#626792

You are welcome

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