• Resolved emyosv

    (@emyosv)


    Hi,
    What is the code to truncate the final ‘s’ (or ‘es’) of a search query so that the singular form of the word show up even if the user typed a plural form. (Vice versa is not a problem because it falls back to fuzzy search.)
    Thanks

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

    (@msaari)

    add_filter('relevanssi_remove_punctuation', 'relevanssi_remove_s', 9);
    function relevanssi_remove_s($term) {
    	$end2 = substr($term, -2, 2);
    	if ("es" == $end2) {
    		$term = substr($term, 0, -2);
    	}
    
    	$end1 = substr($term, -1, 1);
    	if ("s" == $end1) {
    		$term = substr($term, 0, -1);
    	}
    
    	return $term;
    }
    Thread Starter emyosv

    (@emyosv)

    Thank you very much.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Plural ‘s’’ is closed to new replies.