Reply To: qtranslate support and date sorting

Home Forums Product Support Forums Ajax Search Pro for WordPress Support qtranslate support and date sorting Reply To: qtranslate support and date sorting

#3721
Ernest Marcinko
Ernest Marcinko
Keymaster

Hi!

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 :)