Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
Last active November 23, 2017 17:34
Show Gist options
  • Save mgibbs189/59e0517c13be95bbcdb90b2c9c42b4df to your computer and use it in GitHub Desktop.
Save mgibbs189/59e0517c13be95bbcdb90b2c9c42b4df to your computer and use it in GitHub Desktop.
FacetWP - pager handler
function fwp_pager_handler() {
?>
<script>
(function($) {
$(document).on('facetwp-refresh', function() {
if (! FWP.loaded) {
$(document).on('click', '.pagination a', function(e) {
e.preventDefault();
var matches = jQuery(this).attr('href').match(/\/page\/(\d+)/);
if (null != matches) {
FWP.paged = parseInt(matches[1]);
}
FWP.soft_refresh = true;
FWP.refresh();
});
}
});
})(jQuery);
</script>
<?php
}
add_action( 'wp_footer', 'fwp_pager_handler', 100 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment