<?php
/** Add fake facet choices as ghosts - for example if you need to display terms that
* don't have any posts in them yet, and you want them to appear as ghost choices.
* This example is for basic non-hierarchal checkbox, but
* could be adapted for Radio facets.
* Note: allowing users to make non-existant selections can have
* weird side-effects.
*/
add_filter( 'facetwp_facet_html', function( $output, $params ) {
if ( 'categories' == $params['facet']['name'] ) { // adjust name of facet
/** Array of facet_value (the technical value of the choice), facetwp_display_value (the display value of the choice).
* Could be added manually as below, or with some custom code
* to find the values that you need from terms or other sources.
*/
$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);