Newest first always
-
JamesParticipant4 years, 5 months ago #11829
I have a site that’s using wpsolr for search. When you use multiple search words: “one two three”
You will get results newest first for everything that matches “one two three”, then it starts over for “two three one” or “One two” etc.Is there any way to always get chronological order for all the results returned from search?
Thank you
JamesParticipant4 years, 5 months ago #11841When you say unconditionally do you mean there is a setting that ignores relevancy when using sort by date (with multiple keywords)? If so, how would I set that? If there is a hook I can use I am willing to write code for it.
Or did you mean I can set the sort by date but I can’t change the default behavior with multiple keywords?
wpsolrKeymaster4 years, 5 months ago #11842Both.
Default sort is fixed, but there is a hook to update it from code.
Extracted from file wp-content/plugins/wpsolr-pro/wpsolr/pro/extensions/geolocation/class-wpsolr-option-geolocation.php:
add_filter( WPSOLR_Events::WPSOLR_FILTER_DEFAULT_SORT_FIELDS, [ $this, 'wpsolr_filter_default_sort_fields', ], 10, 1 );
* Get geolocation default sort * * @param string $default_sort * * @param WPSOLR_Query $wpsolr_query * * @return string */ public function wpsolr_filter_default_sort( $default_sort, WPSOLR_Query $wpsolr_query ) { if ( $this->get_is_geolocation( $wpsolr_query ) ) { // It's a geolocation search, use default geolocation default sort $geolocation_default_sort = WPSOLR_Service_Container::getOption()->get_option_geolocation_default_sort(); if ( ! empty( $geolocation_default_sort ) ) { // Use default geolocation default sort return $geolocation_default_sort; } } // No default geolocation default sort, or not a geolocation search: use the general default sort. return $default_sort; }
You must be logged in to reply to this topic.