Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Primary result ordering sort by price.
This topic contains 3 replies, has 2 voices, and was last updated by Ernest Marcinko 7 years, 2 months ago.
- AuthorPosts
- September 16, 2016 at 2:03 pm #10148
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
-
This topic was modified 7 years, 2 months ago by
Dimos Tzemanakis.
September 16, 2016 at 2:22 pm #10151Hi!
It’s only possible with a custom function. This should do the trick:
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
September 16, 2016 at 2:47 pm #10152Thanks 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.
September 16, 2016 at 3:23 pm #10153Hi!
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:
$priority_select AS priority,
2. ..and change that line to:
(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,
However this will still not guarantee the same results, but it should be different from the current a bit.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
-
This topic was modified 7 years, 2 months ago by
- AuthorPosts
You must be logged in to reply to this topic.