Skip Navigation

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

Problem:
You are developing a site using the Elementor Search Pro Widget and want the search results to be displayed in the language set by the 'wp-wpml_current_language' cookie. However, any query redirects to the English search result page, even if the query is in another language like French.

Solution:
We recommend enabling the "Language filtering for AJAX operations" in WPML -> Languages. This setting allows the storage of a language cookie to support language filtering for AJAX operations. For more detailed guidance, please visit Enabling Language Cookie to Support AJAX Filtering.

Additionally client added that

...the Elementor Pro Search Widget is not compatible with WPML at the moment. For the filters and AJAX reload, I had to find an solution to circumvent the bug. In this case, I will move to another solution. The simple WP Search for now, and eventually a plugin WPML says is compatible, such as Relevanssi or the more simple Jetsearch.

If this solution does not resolve your issue or seems outdated, 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 for further assistance at WPML Support Forum.

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 3 replies, has 0 voices.

Last updated by mathieuF-14 5 days ago.

Assisted by: Waqas Bin Hasan.

Author Posts
February 17, 2025 at 9:28 pm #16716427

mathieuF-14

Background of the issue:
I am developing a site and using the Elementor Search Pro Widget. I want the search results to be displayed in the language set by the 'wp-wpml_current_language' cookie.

Symptoms:
When I use the Elementor Search Pro Widget, any query redirects me to the English search result page, even if the query is in another language like French.

Questions:
Is there a way to send the user to the language of the 'wp-wpml_current_language' cookie?
Is there a solution to prevent redirection to the English version of the search result page?

February 18, 2025 at 11:42 am #16718551

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting the support.

You can turn on "Language filtering for AJAX operations" in WPML -> Languages, which enables to store a language cookie to support language filtering for AJAX operations.

Please see https://wpml.org/documentation/getting-started-guide/language-setup/enabling-language-cookie-to-support-ajax-filtering/ for more information.

Regards.

February 18, 2025 at 1:52 pm #16719313

mathieuF-14

No, that's not the issue. The cookie is there. I had a similar problem with filters and paginations in loop grids (the posts would switch to the original EN on any AJAX operation), but I was able to force it with this:

<?php
add_action('rest_api_init', function() {
if (isset($_COOKIE['wp-wpml_current_language'])) {
$lang = sanitize_text_field($_COOKIE['wp-wpml_current_language']);
do_action('wpml_switch_language', $lang);
}
});

Now, it is not the cause of the issue for the search, as it has no instidance when disable.

That being said, when I am on a French page and search for a French term, the search does work, it just sends me to the English result page, and I need to toogle back to French to see the result.

Any solution you can suggest? I have tried many things, but it is not working. I basically need to force the toggle. Thanks!

February 19, 2025 at 5:08 am #16721742

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for the updates.

I need to take a closer look at your site. So I request temporary access (WP-Admin and FTP), preferably to a test site where the problem has been replicated.

Your next answer will be private, to share this information safely.

Also provide detailed steps to reproduce the issue and links to pages in the admin and on the frontend.

IMPORTANT: Please take a complete backup of the site to avoid data loss. I may need to activate/deactivate plugins also.

See https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/ for details on privacy and security.

P.S.: If you don't see the section for providing access information, do not write in the message box or the information may appear as public.

February 19, 2025 at 2:53 pm #16725439

mathieuF-14

I have been investigating and it seeam that the Elementor Pro Search Widget is not compatible with WPML at the moment. For the filters and AJAX reload, I had to find an solution to circumvent the bug. In this case, I will move to another solution. The simple WP Search for now, and eventally a plugin WPML says is compatible, such as Relevassi or the more simple Jetsearch.

Thanks for the help!