- This topic has 3 replies, 2 voices, and was last updated 8 years ago by Ernest Marcinko.
-
AuthorPosts
-
September 16, 2016 at 2:03 pm #10148Dimos TzemanakisParticipant
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 8 years ago by Dimos Tzemanakis.
September 16, 2016 at 2:22 pm #10151Ernest MarcinkoKeymasterHi!
It’s only possible with a custom function. This should do the trick:
September 16, 2016 at 2:47 pm #10152Dimos TzemanakisParticipantThanks 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 #10153Ernest MarcinkoKeymasterHi!
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.
-
AuthorPosts
- You must be logged in to reply to this topic.