phpwordpresscode-snippetsadd-filterfacetwp

Facetwp include / exclude facet choices


Okey a quick and simple question :

I installed facetwp I made a facet with the source data properties / amenities taxonomy.

there are a hundred choices. in the facet I want to keep 3 choices for example

(Balcony, Alarm, Garden )

in the documentation this code should do the trick.. but it does not work.

This is what i put

add_filter( 'facetwp_index_row', function( $params, $class ) {
    if ( 'property_amenities' == $params['facet_name'] ) {
        $included_terms = array( 'Balcony', 'Alarm', 'Garden' );
        if ( ! in_array( $params['facet_display_value'], $included_terms ) ) {
            $params['facet_value'] = '';
        }
    }
    return $params;
}, 10, 2 );

if anyone has dealt with this problem or know how to solve it please tell me.


Solution

  • Just wondering have you tried the value modifier in each term. click to view