Last active
July 19, 2019 14:22
-
-
Save mgibbs189/7216e997cdc184a2fb16d1b7d722be06 to your computer and use it in GitHub Desktop.
FacetWP - prettier permalinks for ACF checkbox-based colors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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