<?php
/** add fake facets choices - for example if you need to display terms that
* don't have any posts in them yet
* example is for basic non-hierarchal checkbox
* could be adapted for radio facet
* note: allowing users to make non-existant selections could have
* weird side-affects
*/
add_filter( 'facetwp_facet_html', function( $output, $params ) {
if ( 'categories' == $params['facet']['name'] ) { // adjust name of facet
/** array of facet_value, facetwp_display_value
* could be added manually as below or with some code
* to find the values that you need from terms or other source
*/
$fake_facets = [ 'fake1' => 'Fake 1', 'fake2' => 'Another Fake' ];
$fake_output = '';
foreach ( $fake_facets AS $fake => $fake_display ) {
$fake_output .= '<div class="facetwp-checkbox disabled" data-value="' . $fake . '">' . $fake_display . ' <span class="facetwp-counter">(0)</span></div>';
}
$output = $output . $fake_output;
}
return $output;
}, 10, 2);