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

Reply To: search on multisite

#34156
Ernest MarcinkoErnest Marcinko
Keymaster

Hi!

Thank you for the details.

It should be the case by default, I guess there is some sort of an exception, which does not trigger the re-sorting of the results after all of them are fetched.

I can suggest a custom code to get around this, it is probably the best and fastest possible solution.

function asp_compare_by_relevance( $a, $b ) {
	return $b->relevance - $a->relevance;
}

add_filter( 'asp_results', 'asp_reorder_results_by_relevance', 10, 1 );
function asp_reorder_results_by_relevance( $results ) {
	usort($results, 'asp_compare_by_relevance');
	return $results;
}

Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

Let me know, if this changes anything. Thank you!