This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Primary result ordering sort by price.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #10148
    Dimos TzemanakisDimos Tzemanakis
    Participant

    Hello there,

    Is it possible the primary result ordering sort by price high-> low. Currently the only options are (relevance, title and date). Is there a filter we can add to functions.php?

    Kind Regards,

    Tzemanakis Dimosthenis

    #10151
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi!

    It’s only possible with a custom function. This should do the trick:

    #10152
    Dimos TzemanakisDimos Tzemanakis
    Participant

    Thanks for quick reply.

    This code actually sort results by price but sort the relevance results. If you click here you can see search result sort by price high->low of “sams”. But if sou search sams on ajax search pro it’s not the same.

    #10153
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi!

    It probably won’t be the same, because the sorting is done after the relevance search as a post-process.

    It is unfortunately not possible to sort the query by a custom field value without changing the source code. If you use the regular engine, then you can try the following:

    1. Open up the wp-content\plugins\ajax-search-pro\includes\classes\search\class-asp-search-cpt.php file and go to line 328:

    [php]$priority_select AS priority,[/php]

    2. ..and change that line to:

    [php](SELECT IF(meta_value IS NULL, 0, meta_value) FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_key=’_price’ AND $wpdb->postmeta.post_id=$wpdb->posts.ID) AS priority,[/php]

    However this will still not guarantee the same results, but it should be different from the current a bit.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.