Automatically add facet label as a heading before any facets with available options to filter by.
<?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 );