FacetWP – prettier permalinks for ACF checkbox-based colors

<?php

/**
 * Add to your (child) theme's functions.php
 *
 * This assumes a facet named "color" based on an ACF checkboxes field
 * Each line of the ACF field's "Choices" setting is formatted like: #ff0000 : Red
 *
 * Here we're just stripping the "#" so FacetWP won't automatically hash the value
 */

add_filter( 'facetwp_index_row', function( $params, $class ) {
    if ( 'color' == $params['facet_name'] ) {
        $params['facet_value'] = str_replace( '#', '', $params['facet_value'] );
    }
    return $params;
}, 10, 2 );