→ facetwp_sort_html

Overview

Customize the appearance of the sort box.

To change the sorting logic and options, use the facetwp_sort_options filter.

Parameters

  • $html | string | The sort box output
  • $params | array | Associative array of extra variables (see below)

$params = array(
    'template_name' => 'default',
    'sort_options' => array(
        // See $options within the facetwp_sort_options hook
    )
);

Usage

add_filter( 'facetwp_sort_html', function( $html, $params ) {
    $html = '<select class="facetwp-sort-select">';
    foreach ( $params['sort_options'] as $key => $atts ) {
        $html .= '<option value="' . $key . '">' . $atts['label'] . '</option>';
    }
    $html .= '</select>';
    return $html;
}, 10, 2 );