I am experiencing an issue using WordPress search, and when searching in a secondary language (United States), I get redirected to the default language (Canada) search results page.
For context, I am using the Language URL format - "Different languages in directories" setting. I also added the action to the search form within my theme file following this documentation - https://wpml.org/wpml-hook/wpml_add_language_form_field/.
To replicate the issue go to hidden link enter anything in the search and hit enter to go to the search results page. You will see that once you get to the results the language changes to Canada, the default, even though the &lang=us parameter is there. Is this because I use the "Different languages in directories" setting?
Any assistance to get this working would be appreciated.
Thank you for the follow-up. You are 100% correct, that is the issue I am experiencing.
My question is more how do I actually enforce the search results query page to append the /us/ when searching in the US language? I could not find anything in your documentation about configuring the form to work with language per directory, I only found the query parameter doc - https://wpml.org/wpml-hook/wpml_add_language_form_field/.
In our custom theme I had added some code to change the search query from ?s= to ?search= but even disabling that code block it still does not function as expected.
I figured out the issue after searching several sites and posts. The issue was that I had the form action parameter set to "/" instead of "<?PHP echo home_url() ?>". This now makes the search form lead to the correct language directory.