Skip to content

Instantly share code, notes, and snippets.

@djrmom
Created May 8, 2018 17:30
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 djrmom/65bf1e6590aa85a9e1935dafd679aeeb to your computer and use it in GitHub Desktop.
Save djrmom/65bf1e6590aa85a9e1935dafd679aeeb to your computer and use it in GitHub Desktop.
facetwp replace display values on output
<?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 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment