→ facetwp_selections_html

Overview

This filter lets you customize the selections box HTML.

Parameters

  • $output | string | The selections HTML
  • $params | array | An associative array of selections settings (see below)

$params = array(
    'selections' => array() // associative array of selected values
);

Usage

<?php
function my_facetwp_selections_html( $output, $params ) {

    $output = '';
    $selections = $params['selections'];
    if ( !empty( $selections ) ) {
        $output .= '<ul>';
        foreach ( $selections as $facet_name => $selection_type ) {
            foreach ( $selection_type as $key => $selection ) {
                $output .= '<li data-facet="' . $facet_name . '" data-value="' . $key . '">';
                $output .= '<span>' . $selection . '</span>';
                $output .= '<span class="facetwp-remove-selection"></span>';
                $output .= '</li>';
            }
        }
        $output .= '</ul>';
    }
    return $output;
}

add_filter( 'facetwp_selections_html', 'my_facetwp_selections_html', 10, 2 );

See Also