Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › qtranslate support and date sorting
This topic contains 6 replies, has 2 voices, and was last updated by aerobis 8 years, 8 months ago.
- AuthorPosts
- January 23, 2015 at 1:23 pm #3712
Hey there,
we currently enabled your plugin on our site. Although we enabled Date descending order it does not seem to work.
Also it does not build the search result links correctly for each language. The url does not contain the lanugage information.
So a link will look like:
https://www.aerobis.com/aeroslingAlthough it should look like:
https://www.aerobis.com/de/aerosling or
https://www.aerobis.com/en/aeroslingKeyword suggestions on no results? – OFF
Keyword suggestions language – English
Keyword logic – AND
Category/Term logic – AND
Result ordering – Date descendingFull text search is off
Best,
ElmarJanuary 26, 2015 at 11:13 am #3716Hi!
Try to disable the relevace sorting on the “Relevance Options” panel. The date/title sorting is only secondary if the relevance is enabled.
I googled for similar issues, and there is a known bug with one of the qtranslates filters, where it does not return the correct url if the permalinks are enabled.
The best way around this is to apply a filter on the search results, like this:
add_filter( "asp_results", "asp_qt_correct_url", 1, 1 ); function asp_qt_correct_url( $results ) { foreach ($results as $k=>$v) { // Correct the url manually $results[$k]->link = qtrans_convertURL( $results[$k]->link ); } return $results; }
Put the code above to your themes functions.php file. If the qtranslate documentation is correct, this should solve the issue.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
January 26, 2015 at 2:57 pm #3720Hey,
unfortunately it does not change any of the two behaviors. Relevance was already off. If you like I can keep the plugin activated today so that you can at least check the results:
Best,
ElmarJanuary 26, 2015 at 4:04 pm #3721Hi!
The sorting is indeed a bug, just confirmed it on my test servers. Luckily there is a quick solution in your case. If you open up wp-content/plugins/ajax-search-pro/includes/search_content.class.php and go to lines 545-547, where you should see this:
if (count($all_pageposts)>0) { usort($all_pageposts, array($this, 'compare_by_rp')); }
Please remove of comment out these lines and the date sorting should work immediately. I’ve added this to the known bug list so the soon released next version will contain a bugfix.
I’ve also installed the recent qtranslate to another test server and the code is indeed not working for some reason. After more digging I’ve found that there is a compatibility issue with qtranslate after certain wordpress versions including the function I used. So I figured out another way, which is working on my end.
Try this code instead of the one I provided before:
add_filter( "asp_results", "asp_qt_correct_url", 1, 1 ); function asp_qt_correct_url( $results ) { foreach ($results as $k=>$v) { // Correct the url manually $current_home = trailingslashit(home_url()) . qtrans_getLanguage(); $results[$k]->link = str_replace(home_url(), $current_home, $results[$k]->link); } return $results; }
I hope if will work on your side as well.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
January 26, 2015 at 4:15 pm #3722Ernest,
top notch support. Both issues resolved instantly. Thank you!
Best,
ElmarJanuary 26, 2015 at 4:20 pm #3723Thank you very much, and have a nice day!
If you want, you can leave a rating on the plugin on your codecanyon downloads page, it helps me more than anything.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
January 26, 2015 at 4:29 pm #3724Done!
- AuthorPosts
You must be logged in to reply to this topic.