Tagged: ajax search, polylang, relevanssi
-
AuthorPosts
-
October 22, 2020 at 12:08 pm #1254946
Hi,
since a while I get multilanguage results via the ajax search. The Relevanssi support cannot give me a solution and answers “The Polylang language restriction is a taxonomy parameter. If the Enfold Ajax search overrides the taxonomy parameters, that would remove the Polylang restriction from the search. But as I don’t know what Enfold does, I can’t say if that’s the case. That would explain it, though.”I already implemented your workarounds from your documentation. Doesn’t help. The result page shows the results correct. It’s just the ajax results that’s not working correct.
I already deactivated all plugins to check if there’s a conflict with no results.You can test it via the search in the header on any page.
Any idea what cause the problem?
ThanksOctober 26, 2020 at 4:35 pm #1255763Any news here?
October 27, 2020 at 5:23 am #1255966Hi,
Sorry for the delay. There are still mixed results in the search page when we use the default WordPress search field, so this might not be an issue with the AJAX search. Using the keyword “review” shows posts from both language. (see private field)
Does it work correctly when a default or twenty theme is activated?
Best regards,
IsmaelOctober 27, 2020 at 8:02 am #1255977Hi Ismael, I’ve tested with the 2020 theme. There I’ll get only results from the current language. When I test it with a term I know it’s on the pages, the results are in the current language. I’ve tested with “crm” for example.
Best regards
- This reply was modified 4 years ago by aicompcloud.
November 2, 2020 at 2:20 am #1257483Hey!
Sorry for the delay. Is there a staging or a development version of the site? We would like to further check the issue in the development version of the site.
We might be able to fix the issue with the AJAX search results using the following filter, but it will not work with the default search results. Please add this code in the functions.php file.
/** * Ajax Search Query current language */ function avf_modify_ajax_search_query($search_parameters) { $language = pll_current_language(); parse_str($search_parameters, $params); $params['lang'] = $language; $search_parameters = http_build_query($params); return $search_parameters; } add_filter('avf_ajax_search_query', 'avf_modify_ajax_search_query', 10, 1); function avf_modify_ajax_search_messages($search_messages) { $search_messages[all_results_link] = pll_home_url().'?'.http_build_query($_REQUEST); $search_messages[no_criteria_matched] = '<a class=\'ajax_search_entry ajax_search_entry_view_all\' href=\'' .$search_messages['all_results_link'].'\'>'.$search_messages['view_all_results'].'</a>'; return $search_messages; } add_filter('avf_ajax_search_messages', 'avf_modify_ajax_search_messages', 10, 1);
Cheers!
IsmaelNovember 2, 2020 at 8:46 am #1257528Hi Ismael, I’ve tested it. Staging site login below. It works for the results page. But it didn’t work for the ajax results for example the search in the header bar.
November 7, 2020 at 4:11 am #1258971Hi,
Thank you for the update.
The filter should have only worked for the AJAX search, and not in the default search results page. What happens when you disable the Relevanssi plugin, or re-index the posts?
Best regards,
IsmaelNovember 9, 2020 at 11:01 am #1259204First check deactivating Relevanssi: When I deactivate Relevanssi I only get results from the current language.
But I’m loosing the relevance in results.Second check re-index: I did it, but I still get results from both languages here.
Is there another plugin I could try to bring back the relevance in the results that is compatible to enfold? Or do you have another idea what causes the problem?
November 12, 2020 at 4:51 am #1260044Hi,
We could use the SearchWP plugin instead, then use this snippet in the functions.php file to integrate the plugin search query to the AJAX search form.
// https://kriesi.at/support/topic/ajax-search-search-wp-doesnt-work/#post-1259151
Thank you for your patience.
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.