X Features Cars Demo Power Plants Demo State Parks Demo Site Showcase Docs Tutorials Add-ons Buy

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

$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 );

See Also

facetwp_sort_options