Posted on

Allowing decimal numbers

Relevanssi by default does not support decimal numbers. The decimal points are handled as punctuation and removed. If you want to keep decimal numbers together and make them available in the search, you can add this code to your theme functions.php:

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;

This will keep periods that come after numbers intact.

2 comments Allowing decimal numbers

Leave a Reply

Are you a Relevanssi Premium customer looking for support? Please use the Premium support form.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.