• Resolved user2015

    (@user2015)


    I need to make searchs for numbers with decimals and equal signs (i.e.: 16=1 or 345.56), I added this code (for decimals) to the function file of my child theme but it didn´t work

    add_filter(‘relevanssi_remove_punctuation’, ‘rlv_keep_decimals’, 9);
    function rlv_keep_decimals($a) {
    $a = preg_replace(‘/(\d)\./’, ‘\1PERIOD’, $a);
    return $a;
    }

    add_filter(‘relevanssi_remove_punctuation’, ‘rlv_keep_decimals_2’, 11);
    function rlv_keep_decimals_2($a) {
    $a = str_replace(‘PERIOD’, ‘.’, $a);
    return $a;
    }

    What should I do?
    Thanks very much for your help.

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

    (@msaari)

    This code is exactly correct and should work as expected. Did you rebuild the index after adding the code? That is also necessary.

    Thread Starter user2015

    (@user2015)

    You´re right. Now it works!!
    And what code should I add to include the equal sign into a search?

    i.e.: 16=1 Tomo I

    Thanks

    Plugin Author Mikko Saari

    (@msaari)

    The method is the same:

    add_filter('relevanssi_remove_punctuation', 'rlv_keep_equals', 9);
    function rlv_keep_equals($a) {
    $a = preg_replace('/(\d)=/', '\1EQUALS', $a);
    return $a;
    }
    
    add_filter('relevanssi_remove_punctuation', 'rlv_keep_equals_2', 11);
    function rlv_keep_equals_2($a) {
    $a = str_replace('EQUALS', '=', $a);
    return $a;
    }
    Thread Starter user2015

    (@user2015)

    Thank you very Much Mikko!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Search for numbers’ is closed to new replies.