Created
May 8, 2018 17:30
-
-
Save djrmom/65bf1e6590aa85a9e1935dafd679aeeb to your computer and use it in GitHub Desktop.
facetwp replace display values on output
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 | |
/** 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