Skip to content

Instantly share code, notes, and snippets.

@DavidCramer
Last active August 2, 2017 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidCramer/6e937a27970e3628da94669d425995e3 to your computer and use it in GitHub Desktop.
Save DavidCramer/6e937a27970e3628da94669d425995e3 to your computer and use it in GitHub Desktop.
custom radio facet html
<?php
add_filter( 'facetwp_facet_html', function( $output, $params ) {
if ( 'my_facet' == $params['facet']['name'] ) {
$output = '';
$values = (array) $params['values'];
$selected_values = (array) $params['selected_values'];
foreach( $values as $result ){
$clean_val = esc_attr( $result );
$selected = in_array( $result['facet_value'], $selected_values ) ? ' checked' : '';
$selected .= ( 0 == $result['counter'] && '' == $selected ) ? ' disabled' : '';
$output .= '<div class="facetwp-radio' . $selected . '" data-value="' . $clean_val . '">';
$output .= '<img src="url_to_image/' . $clean_val . '.svg" alt="' . $clean_val . '"> ' . $result['counter'];
$output .= '</div>';
}
}
return $output;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment