Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
Last active July 19, 2019 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgibbs189/7216e997cdc184a2fb16d1b7d722be06 to your computer and use it in GitHub Desktop.
Save mgibbs189/7216e997cdc184a2fb16d1b7d722be06 to your computer and use it in GitHub Desktop.
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 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment