Skip Navigation

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

Problem:

After making any search, if I change the language, the search criteria disappear, and I return to the store.

How can I, for example, search somthing in Portuguese and, after that, change to English, and the results will appear the same but in English?

Solution:

You need to tell WPML those parameter names by a comma-separated list in WordPress Dashboard > WPML > Languages > Language switcher options > Preserve URL arguments.

For more information:

https://wpml.org/documentation/getting-started-guide/language-setup/language-switcher-options/preserve-url-arguments-when-switching-languages/

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

Last updated by Itamar 1 year, 6 months ago.

Assisted by: Itamar.

Author Posts
December 7, 2023 at 7:08 pm #15020511

Sergio Torres

After made any search and if I change the language the search criteria disappear and I return to the store.

How can I do to, for exemple, search some in Portuguese and after that change to English and the results will appear the same but in English?

I disable debug option because I think this is not any issue from wpml but some configuration missing.

Thanks.

December 10, 2023 at 1:46 pm #15031297

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi there,

I will add the first reply before this ticket is assigned to one of my colleagues.

We do need the debug information to know how you setup your website. Maybe if you provide the page in question and tell us how the search is implemented> Is it normal default WordPress search or you sue a plugin?

If you use a plugin please consider that WPML can not know a result without having some context, it might be for example URL parameters that the plugin you use adds for the search results to the browser address bar.

If that is the scenario, you need to tell WPML those parameter names by a comma separated list in WordPress Dashboard > WPML > Languages > Language switcher options > Preserve URL arguments

For more information:

https://wpml.org/documentation/getting-started-guide/language-setup/language-switcher-options/preserve-url-arguments-when-switching-languages/

Thanks.

December 12, 2023 at 12:08 pm #15045497

Sergio Torres

Hi Christopher,

Your solution isn't working. The search bar is native from the theme, at my case Flatsome Theme (exemple: hidden link). you can see in the image attached my code for that search form.

Thanks.

search_code.png
December 12, 2023 at 7:40 pm #15049379

Itamar
WPML Supporter since 02/2016

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi,

I'm not sure that there is a solution for what you are trying to achieve because WPML cannot anticipate the search term that the users of your site will insert in the search bar.

Please answer the following question, and I'll see if we can help further.

Is the code you shared in the screenshot your custom code or Flatsome's built-in code?

Regards,
Itamar.

December 13, 2023 at 9:48 am #15052269

Sergio Torres

Hi,

It's Flatsome's built-in code.

Thanks.

December 13, 2023 at 12:00 pm #15054329

Itamar
WPML Supporter since 02/2016

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi,

We need to replicate this issue on a fresh WordPress installation. Then, if needed, I'll be able to escalate it to our compatibility team. For this, I created a test website with a clean WordPress install. You can access it through this link:

hidden link

With this link, you'll be directly logged in.

Could you please install the Flatsome theme and see if the issue is replicable on a clean WordPress installation?

Please configure WPML and WooCommerce as set on your site (just the basic configurations needed to replicate the issue are enough).

Please also ensure you install the latest version of the Flatsome theme.

Please let us know when everything is finished, and you can replicate the problem. Please also describe the steps to take to see the issue.

Thanks,
Itamar.

December 13, 2023 at 2:11 pm #15055691

Sergio Torres

Hi,

This can't be done without a purchase code to a new instalation to that theme style! I've instaled the base theme but is not exactly the same code to the searchbar. If you need, we have a DEV instalation of the same website that we can share login details, etc.

Thanks.

December 13, 2023 at 3:25 pm #15056673

Itamar
WPML Supporter since 02/2016

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi,

Yes, please share with me access to your dev site.

If you need further help with this, please share the access details to your site with me.
I'm enabling a private message for the following reply.

Privacy and Security Policy
We have strict policies regarding privacy and access to your information. Please see:
https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/
**IMPORTANT**
- - Please backup the site files and database before providing us access. --
-- If you have a staging site where the problem can be reproduced, it is better to share access to the staging site.--

Regards,
Itamar.

December 13, 2023 at 7:26 pm #15058279

Itamar
WPML Supporter since 02/2016

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi, and thanks for the access details.

I must be sure I understand the problem you refer to on your site. I recorded a video. Please watch it here.

hidden link

Is this the problem you have with the search option of the Flatsome theme?

Regards,
Itamar.

December 14, 2023 at 2:41 pm #15065715

Sergio Torres

Hi,

Yes. The poblem is exactly what describe in the video, but with one correction... The URL don't change because the form is in POST method and not because it is AJAX. I've changed the form now to the GET method. Please, redo the same search you have done before and you will see the URL changing getting the "s" variable with the term searched (image attached). And after that, when I go to the English the search goes empty and not with the term searched.

Thanks.

Captura de ecrã 2023-12-14 143907.png
December 17, 2023 at 1:54 pm #15078985

Itamar
WPML Supporter since 02/2016

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi, and thanks for the confirmation.

I continued to check this issue on your dev site as well as on the test site. Here are my findings.

1. The header-main.php file in your Flatsome child theme is custom code. I'm sorry, but we don't debug custom code.

2. WPML's Preserve URL arguments option in WPML -> Languages -> Language Switcher Option does work. I inserted the following arguments, and the arguments are preserved when the language is switched.

s, post_type

I recorded a video (4 minutes) to show you my findings. Please watch it here.

hidden link

If you need further help with what you are trying to achieve regarding your custom code, I would suggest you consider contacting one of our certified partners from this link:

https://wpml.org/contractors/

Before doing so, please have a look here:

https://wpml.org/documentation/about-wpml-contractors/what-type-of-work-you-can-expect-from-contractors/

With our contractors, you might get the custom assistance you need to get on with your project.

Regards,
Itamar.

December 20, 2023 at 3:43 pm #15104429

Sergio Torres

Hi,

The code is based in original theme files as same the child theme that don't also have that files/directories you describe! Anyway... I've added the same arguments in "Preserve URL arguments" option that you have described in video and it works fine.

Thanks.