Skip to content

Instantly share code, notes, and snippets.

@djrmom
Created October 25, 2019 19:12
Show Gist options
  • Save djrmom/bbda4873be2faab7f68a0b182b0b81ed to your computer and use it in GitHub Desktop.
Save djrmom/bbda4873be2faab7f68a0b182b0b81ed to your computer and use it in GitHub Desktop.
facetwp add reset button to flyout
<?php
/** appends your custom html before the facets output **/
add_action( 'wp_head', function() {
?>
<script>
(function($) {
$(function() {
if ('object' != typeof FWP) {
return;
}
FWP.hooks.addFilter('facetwp/flyout/flyout_html', function( flyout_html ) {
var html = `
<button onclick="FWP.reset()">Reset</button>
`;
return flyout_html.replace('{content}', '{content}' + html );
});
});
})(jQuery);
</script>
<?php
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment