Overview

This hook lets you customize the old sort box’s dropdown appearance.

Parameters

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

How to use custom PHP code?

PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More info

$params = [ 'template_name' => 'default', 'sort_options' => [ // See $options within the facetwp_sort_options hook ] ];

Usage

How to use custom PHP code?

PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More info

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

More examples

See also

Last updated: May 2, 2023