Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
Created September 30, 2019 17:11
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/7d3cc6940edf0302217a761068c40df4 to your computer and use it in GitHub Desktop.
Save mgibbs189/7d3cc6940edf0302217a761068c40df4 to your computer and use it in GitHub Desktop.
Automatically replace ampersand "&" with raw &
<?php
// Add to your (child) theme's functions.php
// Make sure to re-index afterwards
add_filter( 'facetwp_index_row', function( $params, $class ) {
if ( 'YOUR_FACET_NAME' == $params['facet_name'] ) {
$params['facet_display_value'] = str_replace( '&amp;', '&', $params['facet_display_value'] );
$params['facet_display_value'] = str_replace( '&#x00026;', '&', $params['facet_display_value'] );
$params['facet_display_value'] = str_replace( '&#38;', '&', $params['facet_display_value'] );
}
return $params;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment