Support » Plugin: Relevanssi - A Better Search » not finding numbers

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

    (@msaari)

    Relevanssi removes punctuation, so it sees “10.02” as “10 02”, which cannot be found, because Relevanssi searches words that have three letters or more by default.

    If you need to search words like that, you need to adjust the punctuation handling.

    add_filter('relevanssi_remove_punctuation', 'rlv_keep_periods_1', 9);
    function rlv_keep_periods_1($a) {
        $a = preg_replace('/(\d)\.(\d)/', '\1PERIOD\2', $a);
        return $a;
    }
    
    add_filter('relevanssi_remove_punctuation', 'rlv_keep_periods_2', 11);
    function rlv_keep_periods_2($a) {
        $a = str_replace('PERIOD', '.', $a);
        return $a;
    }

    Add this to your theme functions.php and rebuild the index. If the code works – I haven’t tested it – it’ll keep all periods that are between two digits.

Viewing 1 replies (of 1 total)
  • The topic ‘not finding numbers’ is closed to new replies.