Index a string of comma-separated values

mgibbs189

{{gist file=”functions.php” lang=”php”}}
<?php

add_filter( ‘facetwp_index_row’, function( $params, $class ) {
if ( ‘categories’ == $params[‘facet_name’] ) {
$values = explode( ‘, ‘, $params[‘facet_value’] );
foreach ( $values as $val ) {
$params[‘facet_value’] = $val;
$params[‘facet_display_value’] = $val;
$class->insert( $params );
}
return false; // skip default indexing
}
return $params;
}, 10, 2 );

{{/gist}}