FacetWP – index parent terms and child terms in separate facets

mgibbs189

{{gist file=”test.php” lang=”php”}}
<?php

function fwp_index_categories( $params, $class ) {
if ( ‘product_cat’ == $params[‘facet_name’] && 0 < (int) $params[‘depth’] ) {
return false; // skip this term
}
elseif ( ‘product_sub_cat’ == $params[‘facet_name’] && 0 == (int) $params[‘depth’] ) {
return false; // skip this term
}
return $params;
}
add_filter( ‘facetwp_index_row’, ‘fwp_index_categories’, 10, 2 );
{{/gist}}