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 14 replies, has 3 voices.
Last updated by jeevanL 3 years, 8 months ago.
Assisted by: Raja Mohammed.
Author | Posts |
---|---|
April 29, 2021 at 11:11 pm #8658001 | |
jeevanL |
Hi, I noticed when someone searches on my site it will only search in the current language, so if someone enters a search term in a different language it will just bring up 0 results. For example, if my website is set to English but the user types a search term in Spanish, it won't bring up the Spanish results. And the same is true the other way round. What I would like is for results from all languages to display regardless of what language the site is on. I read this thread but it seems that these people want the opposite, so I couldn't adapt it: https://wpml.org/documentation/support/creating-multilingual-wordpress-themes/search-form/ My website is: hidden link Thanks. |
April 30, 2021 at 5:39 pm #8664571 | |
Diego Pereira Supporter
Languages: English (English ) Spanish (Español ) Portuguese (Brazil) (Português ) Timezone: America/Sao_Paulo (GMT-03:00) |
Hello, welcome to the WPML support Forum! Before your ticket is assigned to one of my colleagues, please allow me to walk you through some initial debugging steps. This will help speed up the support process. Could you please try with the relevanssi plugin http://wordpress.org/extend/plugins/relevanssi/ - It bypasses the wpml search filters. It was a popular solution for these cases in the past, but it was not tested for a while. So I'm not sure if it still works. If the issue persist, could you please send the search form code snippet to us? Maybe you need to remove the 'wpml_add_language_form_field' action (https://wpml.org/documentation/support/creating-multilingual-wordpress-themes/search-form/) or add Please let us know if it worked for you. |
April 30, 2021 at 11:26 pm #8665523 | |
jeevanL |
Hi Diego, Thanks for your response. I installed relevanssi and it is partially working. It shows the correct results, but when I click on a result from a secondary language is goes to the post of the base language. For example This might just be a simple setting I haven't ticked but I've looked pretty hard. Any ideas? Thanks, |
May 3, 2021 at 9:35 am #8674273 | |
Raja Mohammed Supporter
Languages: English (English ) Timezone: Asia/Kolkata (GMT+05:30) |
Hi Jeevan, I am not sure whether you had any customizations for the search results on the theme, Please give this a try . Disable the Relevassi plugin and add the code snippet to the theme functions.php file. add_action( 'pre_get_posts', 'wpml_custom_query' ); function wpml_custom_query( $query ) { if( is_search() ) { $query->query_vars['suppress_filters'] = true; } } The code basically looks for a search query and tries to remove any additional filters. If you have any customization on the code please let us know the same. Regards |
May 3, 2021 at 1:03 pm #8676541 | |
jeevanL |
Hi Raja, Thanks for your guidance. I did what you said but I still get the same result. I cleared the cache and tested in an incognito window. Perhaps you want to test on your end? 1. Go to sfnonfictionbooks.com For me it just opens the english version of the book. I tried with others too. I'm pretty sure I don't have any customization on the search code. I use a child theme of Generate Press. Here is whats in my functions.php. <?php function generatepress_child_enqueue_scripts() { /** remove_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30 ); global $product; if ( ! $product->add_to_cart_url() ) { $product_url = $product->add_to_cart_url(); do_action( 'woocommerce_before_add_to_cart_button' ); ?> /** /** /** function wpml_custom_query( $query ) { if( is_search() ) { $query->query_vars['suppress_filters'] = true; } } Thanks, |
May 3, 2021 at 2:34 pm #8677339 | |
Raja Mohammed Supporter
Languages: English (English ) Timezone: Asia/Kolkata (GMT+05:30) |
I see the search result page has changed now, Earlier it displayed only the page title now its displaying the contents with a Buy Now button, Not sure if anything else has changed. It would be better if I can reproduce the issue on a fresh installation Please use the test site hidden link The site has WPML install, Kindly configure it similar to your site, Regards |
May 3, 2021 at 10:55 pm #8679355 | |
jeevanL |
Hi Raja, I installed Generate Press and added a couple of test products in English and Spanish. I tested searching for a Spanish product whilst on the English version and it showed no results (same as my site). Then I added the code to the functions php. Now when I search the Spanish product it shows up, but when I click on it I get taken to the English version of the product (same as on my site). So I guess it is reproducing the exact same issue. hidden link Let me know how to proceed. |
May 4, 2021 at 2:41 pm #8686291 | |
Raja Mohammed Supporter
Languages: English (English ) Timezone: Asia/Kolkata (GMT+05:30) |
I have requested assistance from the second tier, I will keep posted with further updates. |
May 4, 2021 at 10:20 pm #8689087 | |
jeevanL |
ok sure. thanks. |
May 5, 2021 at 9:02 am #8691739 | |
Raja Mohammed Supporter
Languages: English (English ) Timezone: Asia/Kolkata (GMT+05:30) |
I checked with the second tier, It is quite difficult to get this working with a piece of code as we are unsetting the filters in the search query which display the posts however it affects the post link generation and the permalinks are returned without WPML filters which is causing the issue. This is considered as custom work, I am afraid I may not be able to assist in this case as it is beyond the scope of this support forum. 🙁 |
May 5, 2021 at 1:40 pm #8695277 | |
jeevanL |
But surely this must be happening to many people. There hasn't ever been a fix for it? Seems like something pretty fundamental - that users get taken to the correct page when clicking on a post... |
May 5, 2021 at 4:49 pm #8697469 | |
Raja Mohammed Supporter
Languages: English (English ) Timezone: Asia/Kolkata (GMT+05:30) |
Basically, the search should not display results from both languages, that is how it should work. We tried a workaround but it is not effective as the filters are not applied to the post URL also the language of the page is different from the searched content the URL is mixed up, I could not think of any other possible solutions to make this work. I tried a few options yet they had more limitations. |
May 5, 2021 at 7:18 pm #8698247 | |
jeevanL |
ok, Well, i appreciate your efforts in any case. "This is considered as custom work" -- is this something you can provide, or can you point me in the right direction for getting it done? |
May 6, 2021 at 10:55 am #8703435 | |
Raja Mohammed Supporter
Languages: English (English ) Timezone: Asia/Kolkata (GMT+05:30) |
Maybe you can check with the contractors if they can help https://wpml.org/contractors/, It is a paid service offered by some of the third-party developers and agencies. |
May 6, 2021 at 1:18 pm #8704895 | |
jeevanL |
Ok great. thanks. Ill check them out. |