qtranslate support and date sorting

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 aerobis 9 years, 3 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #3712
    aerobis
    aerobis
    Participant

    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/aerosling

    Although it should look like:
    https://www.aerobis.com/de/aerosling or
    https://www.aerobis.com/en/aerosling

    Keyword suggestions on no results? – OFF
    Keyword suggestions language – English
    Keyword logic – AND
    Category/Term logic – AND
    Result ordering – Date descending

    Full text search is off

    Best,
    Elmar

    #3716
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

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


    #3720
    aerobis
    aerobis
    Participant

    Hey,

    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:

    https://www.aerobis.com/

    Best,
    Elmar

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


    #3722
    aerobis
    aerobis
    Participant

    Ernest,

    top notch support. Both issues resolved instantly. Thank you!

    Best,
    Elmar

    #3723
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

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


    #3724
    aerobis
    aerobis
    Participant

    Done!

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.