facetwp replace display values on output

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php
/** simple example of find and replace values in the output of a facet’s html
** Be careful that this doesn’t replace unwanted values, you may need to be more
** specific, such as including part of the surround html – ‘>Posts’ to ‘>Articles’ makes
** sure you target the word right after the processing <div> tag.
**/

add_filter( ‘facetwp_facet_html’, function( $output, $params ) {
if ( ‘post_type’ == $params[‘facet’][‘name’] ) {
$current_values = array( ‘Posts’, ‘Products’ );
$replace_values = array( ‘Articles’, ‘For Sale’ );
$output = str_replace( $current_values, $replace_values, $output );
}
return $output;
}, 10, 2 );
{{/gist}}