How to Disable Facet Auto-Refresh and Add a Submit Button
FacetWP automatically refreshes whenever any interaction happens, but it’s possible to disable this if needed:
Prevent the auto-refresh
To prevent FacetWP’s auto-refresh functinality, add the following code to your (child) theme’s functions.php or into the Custom Hooks add-on:
function fwp_disable_auto_refresh() {
?>
<script>
(function($) {
$(function() {
if ('undefined' !== typeof FWP) {
FWP.auto_refresh = false;
}
});
})(fUtil);
</script>
<?php
}
add_action( 'wp_footer', 'fwp_disable_auto_refresh', 100 );
Add an “Apply” or “Submit” button/link to your page
After disabling the auto-refresh functionality, you can add a button to your page to let the user manually apply the facet selections made. You can style the button however you wish. The important part is that the FWP.refresh()
method is triggered on click:
<button onclick="FWP.refresh()">Apply</button>
You can also use a link:
<a href="javascript:;" onclick="FWP.refresh()">Apply</a>