Support » Plugin: Relevanssi - A Better Search » better relevance_score

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mikko Saari


    The problem is, nothing makes that post more valuable than the other posts above it, all of which mention “One piece” in the title as well. The one on top actualle mentions “One Piece” twice in the title, which makes it appear twice as significant.

    If you want to make exact match titles like this appear on top of the results, you need to force it. relevanssi_hits_filter gives you all the tools you need: it gives you an array of search results and the search term. You can go through the results and if the title matches exactly to the search term, move that post first in the results.

    There are some examples in the user manual.

    really thanks,
    here is my wroking code:

    function order_the_results($hits) {
        global $wp_query;
    	foreach ($hits[0] as $hit){
    		if ($search == strtolower($hit->post_title)){
    			array_unshift($hits[0] , $hit);
    	return $hits;
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘better relevance_score’ is closed to new replies.