→ How to Exclude Certain Categories

Occasionally, we need to prevent certain categories from appearing in a facet. This can be done by telling FacetWP not to index those specific terms during the indexing process.

function fwp_exclude_categories( $params, $class ) {

    // The term labels to exclude (EDIT ME)
    $excluded_terms = array( 'Featured', 'Internal', 'Needs Review' );

    // The facet name to target (EDIT ME)
    if ( 'YOUR_FACET_NAME' == $params['facet_name'] ) {
        if ( in_array( $params['facet_display_value'], $excluded_terms ) ) {
            return false;
        }
    }
    return $params;
}
add_filter( 'facetwp_index_row', 'fwp_exclude_categories', 10, 2 );

This code can go into your theme’s functions.php, or in a custom plugin. Make sure to Re-index afterwards.