Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
Created June 25, 2019 16:46
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/33a7f318bf914e06cd1a89ed1a105839 to your computer and use it in GitHub Desktop.
Save mgibbs189/33a7f318bf914e06cd1a89ed1a105839 to your computer and use it in GitHub Desktop.
FacetWP - automatically support taxonomy terms containing numbers
<?php
// Add the following to your (child) theme's functions.php and re-index afterwards
add_filter( 'facetwp_index_row', function( $params, $class ) {
$term_id = (int) $params['term_id'];
$display_value = $params['facet_display_value'];
// If this is a taxonomy term and the display value is numeric,
// Then set facet_value = facet_display_value
if ( 0 < $term_id && is_numeric( $display_value ) ) {
$params['facet_value'] = $display_value;
}
return $params;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment