Created
August 8, 2019 19:14
-
-
Save JiveDig/43567bc161e4873c29b9c9e6791d6170 to your computer and use it in GitHub Desktop.
Automatically add facet label as a heading before any facets with available options to filter by.
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 | |
/** | |
* Adds facet label as a heading before any facets with available options. | |
* | |
* @author Mike Hemberger @JiveDig. | |
* | |
* @param string $output The facet HTML. | |
* @param array $params The shortcode/function parameters. | |
* | |
* @return string The modified output. | |
*/ | |
add_filter( 'facetwp_facet_html', function( $output, $params ) { | |
// Bail if no facet options. | |
if ( empty( $params['values'] ) ) { | |
return $output; | |
} | |
// Return label as heading. | |
return sprintf( '<h3>%s</h3>%s', $params['facet']['label'], $output ); | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment