facetwp_facet_html
Overview
This filter lets you modify a facet’s HTML output.
Parameters
- $output | string | The facet HTML
- $params | array | An associative array of facet settings (see below)
$params = [ 'facet' => [ 'name' => 'my_facet', 'type' => 'checkboxes', 'source' => 'tax/category', // any other facet-specific settings ], 'values' => [], // available for checkbox & dropdown facets 'selected_values' => [ 100, 101 ] ];
Usage
Add a “form-control” CSS class to all dropdown facets:
add_filter( 'facetwp_facet_html', function( $output, $params ) { if ( 'dropdown' == $params['facet']['type'] ) { $output = str_replace( 'facetwp-dropdown', 'facetwp-dropdown form-control', $output ); } return $output; }, 10, 2 );